Beefy Boxes and Bandwidth Generously Provided by pair Networks
P is for Practical
 
PerlMonks  

Re^3: Counting the number of items returned by split without using a named array

by Anonymous Monk
on May 04, 2006 at 12:35 UTC ( [id://547402]=note: print w/replies, xml ) Need Help??


in reply to Re^2: Counting the number of items returned by split without using a named array
in thread Counting the number of items returned by split without using a named array

pretty amazing, that "optimization":
$ perl -MO=Deparse -e '$a = () = split(" ",$_,0)' $a = () = split(" ", $_, 1);

BUT:
$ perl -MO=Deparse -e '$a = () = split(" ",$_,100000)' $a = () = split(" ", $_, 100000);

so it's not completely impossible to use it with split, just limited to a fixed maximum number of fields in the split.
It's a bit unsuspected (at least for me) though, that an explicit  split(" ",$_,0) was 'optimized' also.

Btw - just out of curiosity put this version in the benchmark also - and it's faster than the regexp version, but still slower than  $n = @{[ split ]};

I.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others romping around the Monastery: (5)
As of 2024-04-24 06:01 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found