# Sorts files in $dir and sets $latest->{file} with newest file. my $latest = (sort {$b->{mtime} <=> $a->{mtime}} map {{mtime => -M $_, file => $_}} <$dir/*>)[-1]; my $newM = (stat $latest->{file})[9]; # Sorts files in $dir and sets $oldest->{file} with oldest file. my $oldest = (sort {$a->{mtime} <=> $b->{mtime}} map {{mtime => -M $_, file => $_}} <$dir/*>)[-1]; my $oldM = (stat $oldest->{file})[9]; #### my ($newM, $oldM) = (sort {-M $a <=> -M $b} <./*>)[0,-1];