Beefy Boxes and Bandwidth Generously Provided by pair Networks
"be consistent"
 
PerlMonks  

Re^4: Named Captures

by BrowserUk (Patriarch)
on Oct 06, 2010 at 11:27 UTC ( [id://863762]=note: print w/replies, xml ) Need Help??


in reply to Re^3: Named Captures
in thread Named Captures

Okay. That begins to make sense ;)

But, I discovered that I can get (sort of) what I was after by switching to %-

perl -wE"()='abcde' =~ m[(?<a>a)|(?<b>b)|(?<c>c)|(?<d>d)|(?<e>e)]g and + do{ say for keys %- }" e c a b d

Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
"Science is about questioning the status quo. Questioning authority".
In the absence of evidence, opinion is indistinguishable from prejudice.

Replies are listed 'Best First'.
Re^5: Named Captures
by JavaFan (Canon) on Oct 06, 2010 at 15:02 UTC
    Not quite.
    () = 'abc' =~ /(?<a>a)|(?<f>f)/ and do {say for keys %-}; __END__ a f
    %- will have a key for every named capture in the pattern, whether that capture was involved in the match or not.

      Yes. Hence the "sort of". For my purpose, I just needed to ensure that lots of things got captured, I was never going to do anything with them. I was trying to heavily exercise both named captures and alternations in the hope of reproducing a memory leak.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others about the Monastery: (2)
As of 2024-04-20 05:29 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found