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.
|
|---|
| 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 |