diotalevi has asked for the wisdom of the Perl Monks concerning the following question:
In the regexp /(?{ ... })XXX/, I would like to ensure that the code block is run. When that pattern is applied to " failed ", the optimizer quickly notes that XXX is a required literal and doesn't appear in the string. My code block never fires. Can I force the issue somehow?
" failed " =~ /(?{ $ok = 1 })XXX/; print $ok ? "Good" : "Bad";
Compiling REx `(?{ $ok = 1 })XXX' size 5 Got 44 bytes for offset annotations. first at 1 1: EVAL(3) 3: EXACT <XXX>(5) 5: END(0) anchored `XXX' at 0 (checking anchored) minlen 3 with eval Offsets: [5] 1[14] 0[0] 15[3] 0[0] 18[0]
Guessing start of match, REx `(?{ $ok = 1 })XXX' against ` failed '... Did not find anchored substr `XXX'... Match rejected by optimizer
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: Disabling regexp optimizations?
by japhy (Canon) on Oct 15, 2005 at 18:24 UTC | |
by diotalevi (Canon) on Oct 15, 2005 at 18:28 UTC | |
by japhy (Canon) on Oct 15, 2005 at 18:30 UTC | |
Re: Disabling regexp optimizations?
by graff (Chancellor) on Oct 15, 2005 at 18:44 UTC | |
by diotalevi (Canon) on Oct 15, 2005 at 18:52 UTC | |
by bart (Canon) on Oct 16, 2005 at 00:31 UTC | |
by diotalevi (Canon) on Oct 17, 2005 at 02:26 UTC |
Back to
Seekers of Perl Wisdom