I'm new to Perl and have hit a brick wall trying to make an array of references to hashes. My hosted server has Perl 5.8.8 installed. Here's the relavent part of my code, stripped down. I'm trying to find all files in a directory and for each call the filer function which should make a hash with some information about the file and push a reference to that hash unto an array
@files = (); sub filer { $filepath_rs = $File::Find::name; if(-f $filepath_rs) { $metadata = {}; #should instantiate a new hash object and retu +rn a scalar reference. ${metadata}{'path'} = $filepath_rs; print ${metadata}{'path'}; #prints out fine push(@files, $metadata); #should add reference to hash to arra +y. } } find(\&filer, $mydir); foreach(@files) { print ${$_}{'path'}; #nothing prints out }
In reply to Array of Hashes by tobeythorn
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |