From Code to Community: Sponsoring The Perl and Raku Conference 2025 Learn more

#!/usr/bin/perl
use strict;
use File::LsColor qw(ls_color);
use File::PatternMatch qw(patternmatch);
my $dir = shift;;
not defined $dir and $dir = $ENV{HOME};
my @files = ls_color(glob("$dir/*"));
my $data = patternmatch(256, @files);
for my $i(sort(keys(%{$data}))) {
for my $file(keys(%{$data->{$i}})) {
printf("%03d: %s\n", $i, $file);
}
}