There's more than one way to do things | |
PerlMonks |
Re: Compare the contents of directory with the contents of fileby repson (Chaplain) |
on Feb 24, 2001 at 06:55 UTC ( [id://60600]=note: print w/replies, xml ) | Need Help?? |
I guess you might be storing the list of contents of a
directory in a flat file, and want to check if the current contents differ from the stored record.
In that case I would build a hash of the lines of the file like so: %files = map { tr/\015\012//d; ($_,1); } (<FILE>); Where FILE is an already open filehandle.
Reporting things that weren't in the file and removing the others from the hash. And finally reporting thing from the file that are no longer in the directory: Of course if you are not asking for that, then your question needs clarification. 2001-03-04 Edit by Corion : Removed an erroneous <CODE> tag
In Section
Seekers of Perl Wisdom
|
|