use utf8::all; # Comment out for Windows
use Unicode::Collate;
# No argument: current directory; com. line accepts dir. name.
my $dir = ($ARGV[0] ? shift : '.');
opendir(my $dh, $dir) or die "\n\tCannot open directory : $!\n";
my @list = grep {!/^[\.]{1,2}$/} readdir $dh; #^ skips '.' and '..'
print "$_\n" for @list;
print "\tEnd unsorted\n\n";
my $collator = Unicode::Collate->new(level => 1);
my @entries = $collator->sort(@list);
print "$_\n" for (@entries);
print "\tEnd sorted\n\n";
####
[...]
use Config;
use utf8::all if $Config{osname} eq 'Linux'; # perl adamantly ignores the condition
[...]
##
##
use if $^O ne 'MSWin32', 'utf8::all';
system('chcp 1252') if $^O eq 'MSWin32';