in reply to Sorting based on filesize.

...assuming @files contains the list of filenames in the CWD:

my @sorted = sort { -s $a <=> -s $b } @files;

Or for a more complete example...

use strict; use warnings; { opendir (my $dir, '.') or die "Can't open the directory.\n$!"; local $, = "\n"; print sort { -s $a <=> -s $b } grep -f, readdir($dir); closedir $dir; }

See perlfunc under the -X functions to understand what -s is.


Dave