in reply to Re: special directory entries
in thread special directory entries

Why do people keep trotting out this readdir-and-regexp idiom to deal with current and parent directories?

@dirs = grep($_ ne '.' and $_ ne '..', readdir(DIR));

Sure it's a little more verbose, but it doesn't suffer from sneaky boundary failures (that blakem points out elsewhere in this thread). While it's more verbose, it's also more efficient, as it doesn't need regexp machinery.

Of course, that should be File::Spec::curdir and File::Spec::updir, to be on the safe side.

To find out FMTYEWTK about readdir, '.' and '..', I recommend reading this thread, especially merlyn's reply.

--
g r i n d e r
just another bofh