use strict;
my @f = qw(leo and magalena went down to the basement to get some good
+ scotch they had hidden from their uncle);
@f = sort {$a cmp $b} @f;
for (@f){ print "$_\n";}
This will sort alphabetically. You could also have done a stat on these files and fed all into a hash, then you compare the key values.
Do a search right here on perlmonks for "directory listing" and you may find all kinds of goodies.
If this is *not* going to be a cgi, then yes you can do a call to the system by this for example:
my @sorted_files = split(/\n/, `ls /home/myself/ -S -r`);
This lists everything in my homedir by size in reverse, so... smallest files first. of course, this is no longer perl. Don't get used to backticks if you plan on doing serious webstuff.
|