my @files = (qw( hhk_1sss-(hello).txt hhk_2abc-(hello).txt hhk_3xyz-(hello).txt )); my @new_files = map { /^.*_(\d[a-z]{3}).*(\.txt)$/; "$1$2" } @files;