On Sun, 15 Sep 2002, Steve Fink wrote: : What should this do: : : my $x = "the letter x"; : print "yes" if $x =~ /the { $x .= "!" } .* !/;
Depends. I think it may be necessary for speed and safety reasons to set COW on the string we're matching, so that you're always matching against the original string. Perhaps we can make it work in the specific case of concatenation, since we want to it to work for extensible strings coming from a filehandle. But if a fast implementation needs to keep pointers into a string rather than offsets from the beginning, we're asking for core dumps if the string is modified out from under the pointers, or we have to adjust all known pointers any time the string may be modified. : Does this print "yes"? : : print "yes" if "helo" =~ /hel { .pos-- } lo/; Yes, that isn't modifying the string. : Would it be correct for this to print 0? Would it be correct for this : to print 2? : : my $n = 0; : "aargh" =~ /a* { $n++ } aargh/; : print $n; : : It might want to print zero because if regexes are not required to pay : attention to modifications in the input string, then it can optimize : away the a*. Implementation dependent, but there will probably be a :modifier to specifically turn off optimizations. : What possible outputs are legal for this: : : "aaa" =~ /( a { print 1 } | a { print 2 })* { print "\n" } x/ Lots. :-) Larry