in reply to Argh

Assuming you're doing a numerical comparison on the first part of the filename, you want code rather more like this:
my ($greatest, $gnum) = ('', 0); while($file = readdir DIR) { (my $fnum = $file) =~ /^(\d+)\./; next unless $fnum > $gnum; $gnum = $fnum; $greatest = $file; }
There's room for more polish, but the general idea is there.