I am sure that i am constructing them correctly but when i try to loop though the second key i get the following error. For some reason it does not see $streamID as a hash but as a single variable$hashoffiles->{$streamID}->{$filename} = (modsize, group, user etc...)
My construction code isCan't use string ("1") as a HASH ref while "strict refs" in use at E:\ +Inetpub\cgi-bin\wms.pl line 176.
my looping code is as followsforeach my $dir (@dirList) { if(! -d $dir) { push @failDir, ($dir); next; } find { wanted => sub { #the @fileInfo array is created using the stat function but is irr +elevant for perlmonks my @fileInfo = ($mode, $user, $group, $size, $mtime, $type, $filen +ame, $filepath); #$hashOfStreams has two keys: 1 and 8 #Create a hash of files from source dir for each stream foreach my $key (keys %$hashOfStreams) { #ie $hashOfFiles->{'1'}->{'E:/mame.txt} = [ '$mode', '$user', +'$group'.. ]; #ie $hashOfFiles->{'8'}->{'E:/mame.txt} = [ '$mode', '$user', +'$group'.. ]; $hashOfFiles->{$key}->{$File::Find::name} = [ @fileInfo ]; #the following Debug code prints all vars correctly print "$key $File::Find::name $mode, $user, $group, $size, $mt +ime, $type, $filename, $filepath<br>"; } }, follow => 0}, "$dir"; }
Can anyone who has dealt with complex vars see the problem? I have been looking for hours but cannot see it? Is it possible to create vars as complex as this?foreach $key (sort keys %$hashOfFiles) { #FAILS HERE - ERROR SAYS THAT $key is not a hash but a string foreach my $file (sort keys %$key) { my ($mode2, $user2, $group2, $size2, $mtime2, $filename, $f +ilepath) = @{$hashOfFiles->{$key}->{$file}}; print "$file - $filename, $filepath, $mode2 $user2, $group2, $ +size2, $mtime2<br>"; } }
In reply to hash of hashes of lists!!! by costas
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |