#!/usr/bin/perl use strict; use warnings; my $dir = '/path/to/dir'; opendir my $dirh, $dir or die $!; my @files = map{ [$_, stat( $dir . '/' . $_ )[9]] }grep{ -f $dir . '/' . $_ }readdir $dirh; closedir $dirh; print $_->[0] for sort{ $b->[1] <=> $b->[0] }@files;