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

I tried this line using $dh.  Nothing was getting placed in the array.
Would that be because everything in /usr/bin is an executable file?

> Globs are sorted nowadays, I don't know whether readdir is too.
> 
>
>> Now, your $filenames can also contain names of directories.
> 
> Oops: s/[$]/[EMAIL PROTECTED]/
> 
> 
>>   my @filenames = grep -f, <$processDir/*> ;
>>
>> (but that @filenames uses more memory).
> 
> It uses more memory because the full pathname is in each element.
> 
I figured that was why you brought it up earlier so I have it prepending
the directory name in the foreach loop that runs the stat.  This way I'm
not saving the full path anywhere and only using it long enough to stat
the file.
-- 
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