Beefy Boxes and Bandwidth Generously Provided by pair Networks
Your skill will accomplish
what the force of many cannot

Re: Bizarreness in ?PATTERN? and g

by integral (Hermit)
on Jun 04, 2004 at 15:37 UTC ( #360948=note: print w/replies, xml ) Need Help??

in reply to Bizarreness in ?PATTERN? and g

As has already been said a match in scalar context with /g doesn't 'reset' pos() so that the next match with /g on that variable will start from that position.

The key error in your understanding is that "they're two completely separate regexen". They're not because they're connected by pos() since they have /g.

In first examples using ?? work just the same as the latter case with m// with the once-only nature of ?? just being an additional constraint. ?? works exactly like m// with regards to setting pos() and starting from pos() in scalar context with /g.

So the key point is that the position of the last match is being carried over between the statements, which you weren't expecting.

integral, resident of freenode's #perl

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://360948]
[marioroy]: Hello all. After several attempts, am able to move forward and will soon release a Parallel:: ForkManager compatible MCE::Hobo:: Manager, also MCE::Hobo::Simple, and refactored MCE::Hobo engine supporting multiple instances. Wait works beautifully.
[marioroy]: MCE::Shared has been refined that it allows sharing Tie::File and hash objects containing {fh} key.
[marioroy]: It's taken so long to take Hobo to a new level. Threads-like and Parallel:: ForkManager management capaiblities.
[marioroy]: This will complete the 4 years in the making and likely time to move on to something els.
[marioroy]: s/els/else.

How do I use this? | Other CB clients
Other Users?
Others avoiding work at the Monastery: (10)
As of 2017-05-26 08:24 GMT
Find Nodes?
    Voting Booth?