for (@filenames) { if (/CSS/) { my @t = split /\./; $t[-3] =~ s/CSS$//; $_ = join '.', @t; } }