in reply to Regexp variable substitution of special variable

$replace = '$1 thirdword'; ($varsub = $string) =~ s/$search/$replace/;

Should be replaced with...

$replace = '$1 . " thirdword"'; ($varsub = $string) =~ s/$search/$replace/ee;

...at least that is if you are looking for a solution that is pretty close to what you're attempting.


Dave

Replies are listed 'Best First'.
Re^2: Regexp variable substitution of special variable
by cormanaz (Deacon) on Jul 01, 2005 at 00:23 UTC
    Both this and diotalevi's code works. Thanks for the suggestions. Is one method superior to the other?