I expect m/$foo/ to "recompile" because it could also be m/$foo$bar/
The point of qr is that the inside of $foo=qr// is not effected.
If you don't want it to be recompiled use $str =~ $foo without surrounding m/.../
Your problem seems to arise from the /g "global" switch which is actually changing the whole m operator and not the regex.
Please note that the documentation for qr/STRING/msixpodualn doesn't list /g !
It might help to know that m// and m//g are realized as separate commands in other languages.°
°) e.g. in JS
Cheers Rolf
(addicted to the Perl Programming Language :)
Wikisyntax for the Monastery
In reply to Re^2: On the regex pattern variable to be inserted into another
by LanX
in thread On the regex pattern variable to be inserted into another
by Anonymous Monk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |