Beefy Boxes and Bandwidth Generously Provided by pair Networks
go ahead... be a heretic
 
PerlMonks  

Re^4: Strange behavior of @- and @+ in perl5.10 regexps

by casiano (Pilgrim)
on Sep 12, 2009 at 08:31 UTC ( #794905=note: print w/ replies, xml ) Need Help??


in reply to Re^3: Strange behavior of @- and @+ in perl5.10 regexps
in thread Strange behavior of @- and @+ in perl5.10 regexps

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.


Comment on Re^4: Strange behavior of @- and @+ in perl5.10 regexps
Select or Download Code

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://794905]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others avoiding work at the Monastery: (8)
As of 2015-07-05 15:45 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (67 votes), past polls