foreach $filelist(@filelist) { if ($filelist =~ /FRAUD-REPORT\d+\.CSV/i) { $newfile = $1; push(@curr, $newfile); } sort(@curr); } print "@curr";