#!/opt/perl5.8.6/bin/perl -w use strict; use Time::Local; use Data::Dumper; my $dir = "/pfad/"; my $oldname = 0; my @info = (); my %dif_hash = (); opendir(DIR, "$dir"); #@files = readdir(DIR); my @files = grep{ $_ !~ /\.\.?$/ # filter . und .. and -f $dir.'/'.$_ # \374berpr\374fe, ob es eine datei ist }readdir(DIR); closedir(DIR); print "Inhalt von $dir:\n"; foreach my $file (@files) { #dateiname.20070117.001124.log @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; $dif_hash{ $info[0] } = { begin => { %subhash } }; } else { my %subhash = (); @subhash{ qw/name year month day hour minute second/ } = @info; $dif_hash{ $info[0] } = { end => { %subhash } }; } $oldname = $1; } #print Dumper(\%dif_hash);