in reply to Regex Substitution, Interpolating on the RHS?

my $repl = '"foo$1bar"'; $a = '12345'; $a =~ s/(23)/$repl/ee; print $a,"\n"; $ ./perl /tmp/p 1foo23bar45 $

Dave.

Replies are listed 'Best First'.
Re^2: Regex Substitution, Interpolating on the RHS?
by Cody Pendant (Prior) on Jul 18, 2005 at 12:04 UTC
    Wow. Interesting stuff. Double quotes, double-e... Thank you.


    ($_='kkvvttuu bbooppuuiiffss qqffssmm iibbddllffss')
    =~y~b-v~a-z~s; print

      You should realize this means you're building source code on the fly and evaling it. Its a serious security and correctness issue. The following is equivalent and makes the string-eval more visible than just the second /e would. The first /e is completely different in character than the second /e.

      s<$regex->[0]>{ eval qq["$regex->[1]"]; }e