in reply to Sort directory by file size
That's probably the common trap of readdir: it returns the file names, not file paths.
Fix:
my @sDir = sort { -s "$dir/$a" <=> -s "$dir/$b" } readdir $D1;
If the number of files is high, asking for each file's size several times might slow the program significantly. Schwartzian transform should help.
my @sDir = map $_->[0], sort { $a->[1] <=> $b->[1] } map [ $_, -s "$dir/$_" ], readdir $D1;
($q=q:Sq=~/;[c](.)(.)/;chr(-||-|5+lengthSq)`"S|oS2"`map{chr |+ord }map{substrSq`S_+|`|}3E|-|`7**2-3:)=~y+S|`+$1,++print+eval$q,q,a,
|
---|
Replies are listed 'Best First'. | |
---|---|
Re^2: Sort directory by file size
by nnigam1 (Novice) on May 18, 2016 at 20:20 UTC | |
by graff (Chancellor) on May 19, 2016 at 02:04 UTC | |
by nnigam1 (Novice) on May 19, 2016 at 19:27 UTC | |
Re^2: Sort directory by file size
by nnigam1 (Novice) on May 19, 2016 at 19:25 UTC |
In Section
Seekers of Perl Wisdom