i am developing a web management system and am working with a hash of hashes of lists as so:
$hashoffiles->{$streamID}->{$filename} = (modsize, group, user etc...)
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
Can't use string ("1") as a HASH ref while "strict refs" in use at E:\ +Inetpub\cgi-bin\wms.pl line 176.
My construction code is
foreach 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"; }
my looping code is as follows
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>"; } }
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?

Costas

In reply to hash of hashes of lists!!! by costas

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.