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