Beefy Boxes and Bandwidth Generously Provided by pair Networks
laziness, impatience, and hubris
 
PerlMonks  

Re: Sort directory by file size

by toolic (Bishop)
on May 18, 2016 at 16:00 UTC ( #1163352=note: print w/replies, xml ) Need Help??


in reply to Sort directory by file size

This sorts all files in the current directory by size:
use warnings; use strict; use File::Slurp qw(read_dir); my @files = sort { -s $a <=> -s $b } grep { -f } read_dir('./');

It filters out directories (even . and ..). I'm not sure why you are getting that warning.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1163352]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others avoiding work at the Monastery: (4)
As of 2021-05-10 08:39 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Perl 7 will be out ...





    Results (105 votes). Check out past polls.

    Notices?