Steve Fink wrote: > What should this do: > > my $x = "the letter x"; > print "yes" if $x =~ /the { $x .= "!" } .* !/; > > Does this print "yes"?
If it's allowed at all, I think the match should succeed. > print "yes" if "helo" =~ /hel { .pos-- } lo/; This definitely has to work. But remember the call to C<pos> is on the "match object" (i.e. $0), not 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; Yes. ;-) > What possible outputs are legal for this: > > "aaa" =~ /( a { print 1 } | a { print 2 })* { print "\n" } x/ Unless Larry specifies a required semantics, there are potentially very many acceptable outputs from this, depending on implementation. Therefore, your implementation must print the superposition of all possible outputs. ;-) Actually, I would expect that *any* pattern with closures in it should act as though it were trying each branch and loop in the normal sequence (even if it optimizes that sequence away (which probably means it can't do that optimization in the first place (which means it should act as though it were trying each branch and loop in the normal sequence %-))). Of course, LMMV. Damian