in reply to Re: Opendir error
in thread Opendir error

Don't promote the /^\.{1,2}$/ meme. It doesn't work against malicious people who create files named ..\nfoo. For that you have to use \z instead of $, and by then it is starting to become quite unreadable.

It is much better to write

next if $file eq '.' or $file eq '..';

Of course, a pendant might also go as far as saying

next if $file eq File::Spec->curdir or $file eq File::Spec->updir;

Personally I don't bother with that, but it does make for nice cross-platform code. See special directory entries for another thread on the question.


print@_{sort keys %_},$/if%_=split//,'= & *a?b:e\f/h^h!j+n,o@o;r$s-t%t#u'

Replies are listed 'Best First'.
Re: Re:x2 Opendir error (don't filter with a regex)
by jdporter (Paladin) on Jan 17, 2003 at 16:36 UTC
    Yes. And depending on the processing job, I would encourage the use of !/^\./ whenever possible. Filenames beginning with a dot are supposed to be "hidden", so unless you need to process "hidden" files as well, you should ignore all names that start with a dot.

    jdporter
    The 6th Rule of Perl Club is -- There is no Rule #6.