Iterate through Array of Hashes in a Hash in Perl
arrays, hash, loops, perl
Solution
No need to copy:
foreach my $file (@{ $filelist{file} }) {
print "path: $file->{pathname}; size: $file->{size}; ...\n";
}
Problem
I have an Array of Hashes in a Hash that looks like this: ``` $VAR1 = { 'file' => [ { 'pathname' => './out.log', 'size' => '51', 'name' => 'out.log', 'time' => '1345799296' }, { 'pathname' => './test.pl', 'size' => '2431', 'name' => 'test.pl', 'time' => '1346080709' }, { 'pathname' => './foo/bat.txt', 'size' => '24', 'name' => 'bat.txt', 'time' => '1345708287' }, { 'pathname' => './foo/out.log', 'size' => '75', 'name' => 'out.log', 'time' => '1346063384' } ] }; ``` How can I iterate through these "file entries" in a loop and access its values? Is it easier to copy `my @array = @{ $filelist{file} };` so i only have an array of hashes?