k gefixt :D selbs yay.
ok naechste frage we deklariere ich einen parameter der ein globaler array ist zu einem localem array in der subroutine ?
EDIT: alles geht super danke nochmals und hier ist mein end code dank vayu und renee
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
#!perl
use strict;
use warnings;
#define
my @result;
my $line;
my $key;
my %months;
my %sort_dates;
my @sortedresult;
#read in the data respective with dates etc.
@result = ("AUDIO2-A3.12_P1:project:BmwWtz#1 Wed May 31 13:35:31 2006\n",
"AUDIO2-A3.00_P1:project:BmwWtz#1 Wed Sep 34 11:22:57 2006\n",
"AUDIO2-A3.30_P1:project:BmwWtz#1 Wed Sep 13 00:00:00 1999\n",
"AUDIO2-A2.17_P1:project:BmwWtz#1 Wed Sep 20 30:06:45 1870\n",
"AUDIO2-A5.17_P1:project:BmwWtz#1 Wed Sep 13 17:45:63 2220\n",
"AUDIO2-A9.8:project:BmwWtz#1 Mon May 30 18:18:02 2006\n");
#declare array converting letter months to number months
%months = ( "Jan" => "01",
"Feb" => "02",
"Mar" => "03",
"Apr" => "04",
"May" => "05",
"Jun" => "06",
"Jul" => "07",
"Aug" => "08",
"Sep" => "09",
"Oct" => "10",
"Nov" => "11",
"Dec" => "12"
);
#define sort_dates array
%sort_dates = ();
@sortedresult = (printsorted(@result));
sub printsorted {
my $string_line;
my @result = @_; #declare local parameter
#take the data from months and input it with the rest of the string
foreach $string_line (@_)
{ $string_line =~ tr/ //s; #removes spaces ... wasnt working before but works now
if( $string_line =~ /(.*#[0-9])\s+[a-zA-Z]{3} ([a-zA-Z]{3}) (\d{1,2}) (\d{2}):(\d{2}):(\d{2}) (\d{4})$/ ) { #sorts out sparts via regex
$sort_dates{$7.$months{$2}.$3.$4.$5.$6} = $1;
}
}
#use sort keys to sort array then arrange key with the sorted dates
for $key(sort keys %sort_dates){
print $key,"-rel->",$sort_dates{$key},"\n";
}
return(@sortedresult);
}
\n\n
<!--EDIT|fraggs|1158236351-->
mmm twix