Wie wär's mit
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
#!/opt/perl5.8.6/bin/perl -w
use Time::Local;
my $dir = "/pfad/";
my $oldname = 0;
my %dif_hash;
opendir(DIR, "$dir");
my @files = readdir(DIR);
closedir(DIR);
print "Inhalt von $dir:\n";
foreach my $file (@files) {
#auszulesendedatei.20070117.001124.log
my @info = $file =~ m/(.*)\.(\d{4})(\d{2})(\d{2})\.(\d{2})(\d{2})(\d{2})\.log/;
if ( $info[0] ne $oldname )
{
my %subhash = ();
@subhash{ qw/name year month day hour minute second/ } = @info;
$div_hash{ $info[0] } = {
begin => { %subhash }
};
}
else
{
my %subhash = ();
@subhash{ qw/name year month day hour minute second/ } = @info;
$div_hash{ $info[0] } = {
end=> { %subhash }
};
}
$oldname = $1;
}
print Dumper(\%div_hash);