in reply to look-behind regex
s/^(.*?)foo/my $x=$1; $x.($x=~m[toto]?"foo":"bar")/e [download]
Courage, the Cowardly Dog