Thread Hash von Hashes einstiegsprobleme (19 answers)
Opened by v0id at 2007-03-12 18:01

v0id
 2007-03-13 13:18
#74964 #74964
User since
2005-07-06
33 Artikel
BenutzerIn
[default_avatar]
mein code schaut nun so aus

Code: (dl )
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
#!/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);


mittlerweile kommt als fehlermeldung "nur noch" das hier:

Use of uninitialized value at dir_4.pl line 28.
Use of uninitialized value at dir_4.pl line 33.
Use of uninitialized value at dir_4.pl line 33.

View full thread Hash von Hashes einstiegsprobleme