foreach my $file ( sort { my($as,$an) = $a =~ /^(\D*)(\d+)/; my($bs,$bn) = $b =~ /^(\D*)(\d+)/; $as cmp $bs or $an <=> $bn } keys %hash )