in reply to Help with Regexp substitution using variables

I don't have have an answer, but I can give you some information to make it easier to find. You need recursive variable interpolation. The /e in your regex stands for eval. It executes the result as perl code (see taint checking if you want to start looking into security). Naturally, the evaluation of $reg2 is its contents.

You can use /ee to eval results of the first eval (as Dave suggested). In fact, I believe that you can add 'e's to recursively evaluate as many iterations as you want. For example:

> perl -e "$string='ReplaceMe';$s1='Bug';$s2='$s1';$s3='$s2';$string=~ +s/Me/$s3/eeeg;print $string" > ReplaceBug
I hope this helps.

Replies are listed 'Best First'.
Re: Help with Regexp substitution using variables
by kwokna (Initiate) on Jan 20, 2005 at 17:02 UTC
    Wow, thanks for the quick replies, everyone! I didn't know you could keep adding 'e' to a reg. pretty cool