in reply to find the last lexical entry in a dir without using @ls=readdir

Thanks for the answers. I didn't know gt worked that way on strings but I think you mean
my $max while ( my $file = readdir(DIR) ) { $max = $file if $file gt $max; } print $max;
And yes, I wanted to avoid reading tens of thousands of lines into memory just to get to the last entry. It seemed such a waste.

As for the related question, the reason I asked is because I made a test dir, created new files in there in no particular order and readdir() returned a sorted list. Curious. Just checked with /usr/bin though and it is mostly but not entirely sorted.
  • Comment on Re: find the last lexical entry in a dir without using @ls=readdir
  • Download Code