Beefy Boxes and Bandwidth Generously Provided by pair Networks
The stupid question is the question not asked

Re^4: perl 5.10 bug or not?

by sotona (Scribe)
on Aug 20, 2013 at 15:28 UTC ( #1050200=note: print w/replies, xml ) Need Help??

in reply to Re^3: perl 5.10 bug or not?
in thread perl 5.10 bug or not?

The problem is actually why do I get some capture if I had no previous successful match.

In case of "foo <bar>" I definitely should get two captures, but I have no clue why do I get a capture "" with "" sample. Observed on v5.10.0 DEVEL34916

Replies are listed 'Best First'.
Re^5: perl 5.10 bug or not?
by Corion (Pope) on Aug 20, 2013 at 15:58 UTC

    See perlre:

    NOTE: Failed matches in Perl do not reset the match variables, which makes it easier to write code that tests for a series of more specific cases and remembers the best match.

    $1 and $2 have their old values from a match somewhere else in your code.

    Always guard use of $1 with an if statement to make sure it matched:

    if( m/(.*) <(.*)>/ ) { print "Matched '$1' + '$2'"; } else { print "Did not match"; };

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1050200]
[erix]: but elephant /are/ big
[Discipulus]: Lady_Aleena micro management of code, micro optimization is a pain, you'll brake working things
[Discipulus]: erix you are right but buy a bigger monitor for me then
[Lady_Aleena]: Well, it is done with little pain for now.

How do I use this? | Other CB clients
Other Users?
Others having an uproarious good time at the Monastery: (9)
As of 2017-05-27 20:49 GMT
Find Nodes?
    Voting Booth?