in reply to Re: use qr// variable in right side of s/// operator
in thread use qr// variable in right side of s/// operator

Keep in mind that since the second 'e' causes the content of $str_regexp to be executed as Perl code, it would be dangerous to accept $str_regexp from a remote source such as a web page form. For example, consider what would happen if someone passed "system('rm -rf /')".

Replies are listed 'Best First'.
Re^3: use qr// variable in right side of s/// operator
by brian_d_foy (Abbot) on Feb 15, 2006 at 20:17 UTC

    Well, all the /e's evaluate the replacement string as Perl code. :)

    --
    brian d foy <brian@stonehenge.com>
    Subscribe to The Perl Review

      The first 'e' causes $str_regexp to be evaluated as Perl code. In other words, it uses the value of $str_regexp as the replacement string. That is compiled along with the rest of the program. There's no risk to this.

      The second 'e' causes the content of $str_regexp to be evaluated as Perl code. Since that could have come from anywhere, this is very dangerous.