in reply to Re: A variable name in a regex comment triggers a warning
in thread A variable name in a regex comment triggers a warning
$ perl -wle'use re "debug"; $x = "foo\nbar"; qr/hullo #there $x/x' Compiling REx `hullo #there $x' size 4 Got 36 bytes for offset annotations. first at 1 1: EXACT <hullo>(4) 4: END(0) anchored `hullo' at 0 (checking anchored isall) minlen 5 Offsets: [4] 1[15] 0[0] 0[0] 16[0] Name "main::x" used only once: possible typo at -e line 1. Freeing REx: `"hullo #there $x"'
(Although I can't say that I really understand most of the re 'debug' output :-)
Secondly, why would you want interpolation inside comments anyway? I can see that interpolating a newline into the comment would stop the comment after the newline but to my mind doing the interpolation in the first place is not what you might reasonably expect.
BTW, initialising $deCommafied before the qr{...} also silences the warning for reasons I now understand.
Cheers,
JohnGG
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^3: A variable name in a regex comment triggers a warning
by shmem (Chancellor) on Dec 25, 2006 at 00:27 UTC | |
by johngg (Canon) on Dec 25, 2006 at 01:30 UTC | |
by johngg (Canon) on Dec 25, 2006 at 13:25 UTC |