Beefy Boxes and Bandwidth Generously Provided by pair Networks
No such thing as a small change
 
PerlMonks  

Re^5: 'Dynamic scoping' of capture variables ($1, $2, etc.)

by moritz (Cardinal)
on Dec 19, 2012 at 06:21 UTC ( #1009507=note: print w/ replies, xml ) Need Help??


in reply to Re^4: 'Dynamic scoping' of capture variables ($1, $2, etc.)
in thread 'Dynamic scoping' of capture variables ($1, $2, etc.)

As per your code, your m// expression will match first digits ( 55 ) at all time as per my understanding

No, because I used m/../g in scalar context, which remembers the previous match position in pos, and then always returns the next match during subsequent calls.

Maybe you are more familiar with it in this idiom:

use 5.010; $_ = 'a123b45c6'; while (m/(\d+)/g) { say $1; }


Comment on Re^5: 'Dynamic scoping' of capture variables ($1, $2, etc.)
Select or Download Code
Re^6: 'Dynamic scoping' of capture variables ($1, $2, etc.)
by nvivek (Vicar) on Dec 20, 2012 at 07:16 UTC
    Thanks for your explanation. I got it.

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others surveying the Monastery: (4)
As of 2014-09-16 06:44 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    My favorite cookbook is:










    Results (157 votes), past polls