my $replace = '"$2ead"'; $s1 =~ s/$pattern/++$k && $replace/gee;