djw has asked for the wisdom of the Perl Monks concerning the following question:
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: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++; } }
This would produce something like:print "$fileinfo{$md5hash}{path}[0]\n"; print "$fileinfo{$md5hash}{path}[1]\n"; print "$fileinfo{$md5hash}{path}[2]\n";
But that assumes I know how many elements are in the array. My question is how do I iterate over the anonymous array?/home/djw/foo /home/djw/foo/bar /home/djw/foobar
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: How to reference a nested anonymous array
by Abigail-II (Bishop) on May 28, 2002 at 14:13 UTC | |
Re: How to reference a nested anonymous array
by Rich36 (Chaplain) on May 28, 2002 at 14:09 UTC | |
(tye)Re: How to reference a nested anonymous array
by tye (Sage) on May 28, 2002 at 15:55 UTC | |
Re: How to reference a nested anonymous array
by shelob101 (Sexton) on May 29, 2002 at 03:52 UTC | |
by dmmiller2k (Chaplain) on May 29, 2002 at 05:19 UTC | |
Re: How to reference a nested anonymous array
by redemption (Sexton) on May 29, 2002 at 09:03 UTC |