On Wed, Dec 19, 2001 at 11:43:15AM +1100, George Vieira wrote:

> Again with this globbing.. I can't see anything about using glob in reverse
> order only using nosort. 
> 
> I'm using this:
> 
> my $dir = "./news/*.n";
> @files = glob("$dir");

from "perldoc -f sort":

       sort SUBNAME LIST
       sort BLOCK LIST
       sort LIST
               Sorts the LIST and returns the sorted list value.

one of the examples given is:

       # same thing in reversed order
       @articles = sort {$b cmp $a} @files;

use '<=>' instead of 'cmp' if you want to sort numerically
instead of lexically (see the perlfunc manpage for more
information), e.g. "@files = sort {$b <=> $a} @files;".  so glob
the directory first, then sort it afterward.


-- 
#ozone/algorithm <[EMAIL PROTECTED]>          - trust.in.love.to.save

-- 
SLUG - Sydney Linux User Group Mailing List - http://slug.org.au/
More Info: http://lists.slug.org.au/listinfo/slug

Reply via email to