in reply to defering substitution within double-quoted strings?
$pattern = qr/r(.)(.)/; my $replace = sub { "$_[0]ead" }; $s1 =~ s/$pattern/++$k && $replace->( $2 )/ge; [download]