Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl: the Markov chain saw
 
PerlMonks  

Re^3: How can I access the number of repititions in a regex?

by Errto (Vicar)
on Mar 11, 2008 at 20:36 UTC ( #673610=note: print w/replies, xml ) Need Help??


in reply to Re^2: How can I access the number of repititions in a regex?
in thread How can I access the number of repititions in a regex?

I understand that the empty () imposes list context on the right...
correct
...making the match return the number of matches.
Not quite. The match returns a list of matches. A list assignment in scalar context returns the number of elements in the list, regardless of the number of those elements that actually get assigned to anything (in this case, zero). So the "5" doesn't propagate. It's the use of the assignment in scalar context that creates the "5".
  • Comment on Re^3: How can I access the number of repititions in a regex?

Replies are listed 'Best First'.
Re^4: How can I access the number of repititions in a regex?
by amarquis (Curate) on Mar 12, 2008 at 03:19 UTC
    Ah, thank you. Sorry, I don't know why I was confusing the two, it doesn't even make sense the way I was thinking about it.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://673610]
help
Chatterbox?
LanX reigned by the Duke of Normandy
[davies]: LanX: Politicians making jobs for each other, really. Results in unnecessary complications and tax bills with up to 5 levels of Govt busily inventing new crimes for people to commit.

How do I use this? | Other CB clients
Other Users?
Others studying the Monastery: (9)
As of 2017-12-15 18:27 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    What programming language do you hate the most?




















    Results (441 votes). Check out past polls.

    Notices?