in reply to Re: Print the oldest file in a directory.
in thread Print the oldest file in a directory.

Methinks there is some kind of optimization going on. Perhaps perl knows that a sorted array in scalar (or void?) context is just the length of the array, and so the sort can be optimized away in the first case? Also, you really should take the glob out of the equation (it's an expensive operation and heavily skews the results of the benchmark). I get the ST being more than twice as fast with this (also you have '$a <=> $b' in one, and '$b <=> $a' in the other & BTW I have about 63 files in the directory):
use Benchmark; opendir(DIR, ".") or die "Acck: $!"; my @files = readdir DIR; closedir DIR; my $num_files = @files; print "$num_files\n"; timethese(-4, { 'chad' => \&chad, 'swartz' => \&st,}); sub chad { my @list = sort{ (-M $b) <=> (-M $a) } @files; } sub st { my @list = map { $_->[0] } sort { $b->[1] <=> $a->[1] } map { [$_, -M] } @files; }