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.
|