in reply to how to do effective sort in perl

You didn't say what you wanted to optimize, so here's another take on it:

my @filenames = do { opendir my $d, "." or die; sort readdir $d };
Note that this only works on modern perls.