Dr.Ruud wrote:
> "Dr.Ruud" schreef:
>> Mathew Snyder:
> 
>>> foreach my $file (sort(readdir DH)){
>>>         push @filenames, $file;
>>> }
>> You sort too early.
> 
> Ignore that. Just use John's alternative:
> 
>   my @filenames = sort readdir DH;
> 
> or make that
> 
>   my @filenames = sort grep -f, readdir DH;
> 
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;




-- 
Mathew

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