for (@filenames) { s{ # substitute CSS # the string CSS ( # and a capture consisting in \. # a literal dot, [^\.]+ # any number of non-dots, \. # another literal dot, ErrorLog # and the constant ErrorLog ) # (end of capture) $ # anchored at the end of the string } {$1}x; # against the capture above }