On Mon Jan 17 08:49:39 2005, philippe.verdret@xps-pro.com wrote: > > This is a bug report for perl from pverdret@xps-pro.com, > generated with the help of perlbug 1.35 running under perl v5.8.4. > > In a capture a reference to this capture is perfectly possible: > > "baaa" =~ (\1|a)+ > > the result of this match is b<aaa>. When I try out this code (or any of the subsequent examples) *as is*, I get syntax errors. ##### $ perl -e '"baaa" =~ (\1|a)+' syntax error at -e line 1, at EOF Execution of -e aborted due to compilation errors. ##### But when I modify each of the code samples to make a proper regular expression, I do not get the output the OP described: > If I replace the back-reference \1 by a conditional expression like > this: > > "baaa" =~ ((?(1)a|a))+ > > the result is the same. The tested condition is > independant of the capture content so if i change the regex like this: > > "baaa" =~ ((?(1)a|b))+ > > the result should be "<baaaa>". But the matched string is <b>aaaa. > > By introducing a (?{}) behind "b" the result is now right: > > "baaa" =~ ((?(1)a|b(?{})))+ > > use re 'debug' indicates that the empty code block changes the > generated opcodes. > > Philippe Verdret > ##### $ perl -e '"baaa" =~ m/(\1|a)+/;print "$1\n"' a $ perl -e '"baaa" =~ m/((?(1)a|a))+/;print "$1\n"' a $ perl -e '"baaa" =~ m/"baaa" =~ ((?(1)a|b))+/;print "$1\n"' $ perl -e '"baaa" =~ m/"baaa" =~ ((?(1)a|b(?{})))+/;print "$1\n"' ##### So either I'm misinterpreting the OP, or his original premise was incorrect, or Perl has changed since this was posted seven years ago. Which? Thank you very much. Jim Keenan --- via perlbug: queue: perl5 status: new https://rt.perl.org:443/rt3/Ticket/Display.html?id=33820Thread Next