opendir my $d, $dir; my @f = sort { -M $b <=> -M $a } readdir $d; unlink @f[-0,1] if @f > 20;