Deleting most recent files by parsing filename
You can reduce number of loops, sorts, and matches, so this should perform faster,

my $num_to_keep = 2;

my $dir = "/home/mp3files";
opendir my $DH, $dir or die "$! $dir";

# only mp3s
my $fileRE = qr/(.+) _ (\d{4}-\d{2}-\d{2}) \.mp3$/x;

my %count;
# files to delete
my @files = map {
  my $basename = $_-&gt;[1];
  (++$count{$basename} &gt; $num_to_keep) ? $_-&gt;[0] : ();
}
sort {
  $b-&gt;[2] cmp $a-&gt;[2] # sort descending by date
}
map {
  my @match = /$fileRE/;
  (@match &amp;&amp; -f "$dir/$_") ? ["$dir/$_", @match] : ();
}
readdir($DH);

close $DH;
unlink(@files);