The deferred interpolation of scalars in a regex can still be depended on if the deference of all the various interpolations involved can be synched up properly.
(However, I share the suspicions of others about this approach to what seems like a templating problem.)
>perl -wMstrict -le "my $rx = qr{ foo/bar }xms; print $rx; ;; my $str = 'xx foo/bar yy'; eval qq{ print q{match} if \$str =~ \$rx; my \$ry = q{$rx}; print qq{captured '\$1'} if \$str =~ m/(\$ry)/; }; $@ and die qq{eval err: $@}; " (?^msx: foo/bar ) match captured 'foo/bar'
Update: Slightly altered example code to more closely match my previous post.
In reply to Re: Putting the stringified Regexp object into code
by AnomalousMonk
in thread Putting the stringified Regexp object into code
by sedusedan
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |