http://qs321.pair.com?node_id=469342

Win has asked for the wisdom of the Perl Monks concerning the following question:

Can anyone suggest a Perl script that will check the number of files in a folder and delete the oldest two files, if there are more than 20 files present in the folder? Somebody has kindly given me the following bit of code:
opendir my $d, $dir; my @f = sort { -M $b <=> -M $a } readdir $d; unlink @f[-0,1] if @f > 20;
Can anyone please expand this? Perhaps a detailed explanation. Or suggestions for improvement.