EyeOpener has asked for the wisdom of the Perl Monks concerning the following question:
I want to test this behavior, but I can't seem to make /o ignore changes to variables in the regex. I thought this meant that variables would be interpolated and the regex would be compiled only once (the first time it's encountered), and that if a variable within the regex has changed the next time the pattern is evaluated, that change will be ignored. This doesn't seem to be the case.
Here's the code I'm testing with:
while (1) { print "Enter regex: "; chomp ($regex = <>); print "Enter string: "; chomp ($str = <>); print "Matches!\n" if $str =~ /$regex/o; }
I would expect that in the second iteration (and all future iterations) through the loop, the input into $regex would be effectively ignored, but that doesn't seem to be the case. Have I misinterpreted /o, or is my code bogus? Thanks!
Peter
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
ActiveState /o regex modifier bug
by EyeOpener (Scribe) on Jul 18, 2002 at 19:39 UTC | |
|
Re: Use of /o regex modifier?
by kvale (Monsignor) on Jul 18, 2002 at 18:55 UTC | |
by EyeOpener (Scribe) on Jul 18, 2002 at 19:19 UTC | |
|
Re: Use of /o regex modifier?
by PodMaster (Abbot) on Jul 18, 2002 at 21:32 UTC | |
by EyeOpener (Scribe) on Jul 19, 2002 at 23:10 UTC |