in reply to Re^2: A variable name in a regex comment triggers a warning
in thread A variable name in a regex comment triggers a warning
Firstly, why the difference between qr{(?x)...} and qr{...}x?
I guess that has to do with the stages of regex compilation. After the closing token for qr{ is found, the outer flags are checked. If there's an x modifier for the whole regex, comments will be stripped. Then variable interpolation is done. After that, the pattern is compiled, and it's at this stage the internal starting (?x) is seen. Alas, variables are already interpolated, which in your case generated a warning. Comments are then stripped to the end of the pattern (or the next (?-x)modifier).
Does that make sense? If what I describe is the case, it would answer your second question too.
-shmem
_($_=" "x(1<<5)."?\n".q·/)Oo. G°\ /
/\_¯/(q /
---------------------------- \__(m.====·.(_("always off the crowd"))."·
");sub _{s./.($e="'Itrs `mnsgdq Gdbj O`qkdq")=~y/"-y/#-z/;$e.e && print}
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^4: A variable name in a regex comment triggers a warning
by johngg (Canon) on Dec 25, 2006 at 01:30 UTC | |
|
Re^4: A variable name in a regex comment triggers a warning
by johngg (Canon) on Dec 25, 2006 at 13:25 UTC |