in reply to RegEx - Using Templates

You have several problems there. Your substitution string must be evaluated twice to get the $1 and $2 interpolated. Evaluation, however, does not like the regex style backwhack in $v2, and will simply take a bare dot to mean concatenation. Modify your code to something like this:

$text = 'Cheese.Bacon'; $v1 = qr/(\w+)\.(\w+)/; $v2 = 'qq($2.$1)'; $text =~ s/$v1/$v2/ee;
I added use of qr() for $v1, but what you had was ok.

After Compline,
Zaxo

Replies are listed 'Best First'.
Re: Re: RegEx - Using Templetes
by Anonymous Monk on May 29, 2003 at 13:19 UTC
    You guys are awesome. the qq{...} worked perfectly. Thanks so much!