public
Created

Print files by length

  • Download Gist
files.pl
Perl
1 2 3 4 5 6 7 8 9
use v5.14;
 
my %files = map { length($_) => $_ } glob('*');
my $count = shift;
 
foreach my $length (sort {$a <=> $b} keys %files) {
say $files{$length};
--$count or last;
}
files2_str.pl
Perl
1
say join("\n", map /^\d+ (.*)/, (sort {$a <=> $b} map { length($_) . " $_" } glob('*'))[0..(shift)-1]);

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.