![]() |
|
P is for Practical | |
PerlMonks |
Re: Finding un-paired files in a directoryby Corion (Patriarch) |
on Dec 02, 2003 at 11:42 UTC ( #311586=note: print w/replies, xml ) | Need Help?? |
Personally, I would use a different approach by restating the problem: You are interested in all *.mrg files that have no corresponding *.did file :
My method might be a bit slower, as for each .mrg file, an additional call to stat will be made, which can be very slow on full directories, but I think that the shorter code makes up for the slower code. If speed should really become an issue, I'd readdir the directories contents into a hash and then check for existence in the hash much like your example:
Also, I don't think that production code should contain references to Perlmonks node IDs, but rather an explanation of what happens :
Update: Added "faster" alternative Update 2: Fixed code in response to merlyns bugfinding
In Section
Seekers of Perl Wisdom
|
|