Mathew Snyder <[EMAIL PROTECTED]> wrote:
> Did a bit o' Googling and found how to use the 'not' operator 
> and now have this line that eliminates the . and .. while 
> still populating the array in as few lines as possible:
> 
> @filenames = sort grep { !/^\.$|^\.\.$/ } readdir $dh;

You can optimise this further:

@filenames = sort grep !/^\.\.?$/, readdir $dh;

I'm assuming that this regex would be faster, too, since it
does not contain an alternation.

HTH,
Thomas

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>


Reply via email to