in reply to A variable name in a regex comment triggers a warning
If you have a newline in $deCommafied, there certainly will be an effect; anything after the newline isn't part of the comment:
$ perl -wle'use re "debug"; $x = "foo\nbar"; qr/(?x)hullo #there $x/' Compiling REx `(?x)hullo #there foo bar' size 4 Got 36 bytes for offset annotations. first at 1 1: EXACT <hullobar>(4) 4: END(0) anchored `hullobar' at 0 (checking anchored isall) minlen 8 Offsets: [4] 5[20] 0[0] 0[0] 25[0] Freeing REx: `"(?x)hullo #there foo)\nbar"'
FWIW, using qr{ ... }x; instead of qr{(?x) ... }; seems to do what you expect. But I'd try to avoid relying on that. Also watch out for having your end-quote character ('}' in your example) in the comment.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: A variable name in a regex comment triggers a warning
by johngg (Canon) on Dec 24, 2006 at 23:10 UTC | |
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 |