Beefy Boxes and Bandwidth Generously Provided by pair Networks
Keep It Simple, Stupid
 
PerlMonks  

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

by JavaFan (Canon)
on Sep 11, 2009 at 21:29 UTC ( [id://794856]=note: print w/replies, xml ) Need Help??


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

But it would be useful if they do so.
Yes, but that doesn't mean the current (non)behaviour is a bug.

Wishes are nice, but at the moment there's only just one guy doing any serious work on the regexp engine. And he's swamped already.

Patches will always be welcome.

Replies are listed 'Best First'.
Re^4: Strange behavior of @- and @+ in perl5.10 regexps
by casiano (Pilgrim) on Sep 12, 2009 at 08:31 UTC
    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.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others chilling in the Monastery: (4)
As of 2024-03-19 11:42 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found