javafan,

Thanks for your comments

... I don't think @- and @+ are guaranteed to contain anything meaningful during a match, so it would be hard to say there's a bug.
Observe that the main anomaly, i.e., the fact that @- and @+ have different lengths occurs at the end of the regexp parsing, not during the intermediate process. See the following variant of the former example:
pl@nereida:~/Lperltesting$ cat -n ./offsetsin5_10_end.pl 1 #!/usr/local/lib/perl/5.10.1/bin//perl5.10.1 2 use v5.10; 3 4 my $input; 5 6 local $" = ", "; 7 8 my $parser = qr{ 9 ^ 10 ((?&expr)) 11 ((?&expr)) 12 \z 13 (?{ 14 say "main:\n\@- = (@-)\t\t ".scalar(@-)." items\n +\@+ = (@+)\t ".scalar(@+)." items\n"; 15 }) 16 17 (?(DEFINE) 18 (?<expr> 19 (.) (.) 20 (?{ 21 say "expr:\n\@- = (@-)\t ".scalar(@-)." items +\n\@+ = (@+)\t ".scalar(@+)." items\n"; 22 }) 23 ) 24 ) 25 }x; 26 27 $input = <>; 28 chomp($input); 29 if ($input =~ $parser) { 30 say "matches: ($&)"; 31 say "At the very end:\n\@- = (@-)\t ".scalar(@-)." items\n\@ ++ = (@+)\t ".scalar(@+)." items\n"; 32 }
The only new line is line 31. When executed says:
pl@nereida:~/Lperltesting$ ./offsetsin5_10_end.pl abab expr: @- = (0, , , , 0, 1) 6 items @+ = (2, , , , 1, 2) 6 items expr: @- = (0, 0, , , 2, 3) 6 items @+ = (4, 2, , , 3, 4) 6 items main: @- = (0, 0, 2) 3 items @+ = (4, 2, 4, , , ) 6 items matches: (abab) At the very end: @- = (0, 0, 2) 3 items @+ = (4, 2, 4, , , ) 6 items
Apologies for not being able to help sending a patch. I would like to have the required knowledge to do it.


In reply to Re^4: Strange behavior of @- and @+ in perl5.10 regexps by casiano
in thread Strange behavior of @- and @+ in perl5.10 regexps by casiano

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.