in reply to Compare the contents of directory with the contents of file
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.
Then I would loop over the directory like so (where DIR comes from opendir):
Reporting things that weren't in the file and removing the others from the hash.while (defined($_ = readdir(DIR))) { next if /^\.\.?$/; unless (delete $files{$_}) { print "New: $_\n"; } }
Of course if you are not asking for that, then your question needs clarification.for (keys %files) { print "Gone: $_\n"; }
2001-03-04 Edit by Corion : Removed an erroneous <CODE> tag
|
---|