![]() |
|
Perl-Sensitive Sunglasses | |
PerlMonks |
Re: Only the last file data is getting saved in the hashby biohisham (Priest) |
on Nov 07, 2010 at 07:47 UTC ( [id://869872]=note: print w/replies, xml ) | Need Help?? |
iphone post a self contained boil-down of this code that actually works and demonstrates the problem you're experiencing rather than a snippet that needs fixing..
Another notice, in the first line while(<$DATA>), you don't really want to use names similar to special literals like DATA as your filehandle names, that may lead to confusion in case someone took up to maintain your code since DATA is connected with the special token __DATA__, read perldata->special literals and SelfLoader. Where does your while loop end? How did the %Hash_filenames come to existence? Depending on a test sample of your file names that you're searching, what do you expect each one of the hashes you've used to contain? When you say only the last file 'data' is getting saved in the hash, is 'data' reflective of the file name or the file contents? in both cases however, you may be experiencing this because something is getting overwritten with every iteration of the loop ... I tried cleaning up your code a little bit to get it working but I don't have any parameters to reproduce the behavior you're describing
Take it from here and read How di I post a question effectively? Excellence is an Endeavor of Persistence. A Year-Old Monk :D .
In Section
Seekers of Perl Wisdom
|
|