Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl Monk, Perl Meditation

Re^3: No questions. Just a "thank you for named captures" !!

by sedusedan (Monk)
on Feb 07, 2013 at 16:50 UTC ( #1017695=note: print w/replies, xml ) Need Help??

in reply to Re^2: No questions. Just a "thank you for named captures" !!
in thread No questions. Just a "thank you for named captures" !!

$ perl -MBench -e'$s = "a b"; /(\w+) (\w+)/; bench sub {$a=$1; $b=$2}, + -1' 3666664 calls (3339959/s), 1.098s (0.0003ms/call) $ perl -MBench -e'$s = "a b"; /(?<a>\w+) (?<a>\w+)/; bench sub {$a=$+{ +a}; $b=$+{b}}, -1' 636364 calls (560973/s), 1.134s (0.0018ms/call) $ perl -MBench -e'$s = "a b"; /(?<a>\w+) (?<a>\w+)/; %h=(a=>$+{a}, b=> +$+{b}); bench sub {$a=$h{a}; $b=$h{b}}, -1' 3333331 calls (3102372/s), 1.074s (0.0003ms/call)

Accessing %+ elements is slower due to some tie magic. In general, yeah, you don't need to worry about it. But I managed to make Org::Parser and Text::sprintfn around twice as fast by avoiding named capture or copying %+ first to a temporary hash instead of accessing invididual %+ elements repeatedly.

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1017695]
and the questions are moot...

How do I use this? | Other CB clients
Other Users?
Others drinking their drinks and smoking their pipes about the Monastery: (4)
As of 2018-06-19 22:17 GMT
Find Nodes?
    Voting Booth?
    Should cpanminus be part of the standard Perl release?

    Results (115 votes). Check out past polls.