I have a hash with a nested anonymous hash that holds an anonymous nested array. I have my data in the array and I can access it (print for example) without a problem. I have tried to reference the array, but I think I'm having a problem with syntax because its an anonymous array.


What I can't do is iterate over the array because I don't know how to reference it. Here is some code to show you what is going on:
if (-f) { my $fsize = stat($_)->size; if ($fsize > MINFILESIZE) { open(MD5FILE, "$_") || warn "Can't open file ($_): ($!)\n" +; binmode(MD5FILE); my $md5hash = Digest::MD5->new->addfile(*MD5FILE)->hexdige +st; close(MD5FILE); if (exists($fileInfo{$md5hash})) { $fileInfo{$md5hash}{path}[$fileInfo{$md5hash}{count}] += $File::Find::dir; $fileInfo{$md5hash}{count} += 1; } else { $fileInfo{$md5hash}{filename} = $_; $fileInfo{$md5hash}{size} = $fsize; $fileInfo{$md5hash}{count} = 1; $fileInfo{$md5hash}{path}[0] = $File::Find::dir; } } $totalFiles++; } }
I am using File::Find to search for any duplicate files on a volume of a certain size with the same MD5 sig. I want to track each duplicate file in my hash, and I want to keep the path info for each duplicate in my annonymous array. Using my code above, the correct info gets put into the array and I can even print it out doing this:
print "$fileinfo{$md5hash}{path}[0]\n"; print "$fileinfo{$md5hash}{path}[1]\n"; print "$fileinfo{$md5hash}{path}[2]\n";
This would produce something like:
/home/djw/foo /home/djw/foo/bar /home/djw/foobar
But that assumes I know how many elements are in the array. My question is how do I iterate over the anonymous array?

djw

In reply to How to reference a nested anonymous array by djw

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.