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:
I added use of qr() for $v1, but what you had was ok.$text = 'Cheese.Bacon'; $v1 = qr/(\w+)\.(\w+)/; $v2 = 'qq($2.$1)'; $text =~ s/$v1/$v2/ee;
After Compline,
Zaxo
In reply to Re: RegEx - Using Templetes
by Zaxo
in thread RegEx - Using Templates
by Anonymous Monk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |