Beefy Boxes and Bandwidth Generously Provided by pair Networks
Don't ask to ask, just ask
 
PerlMonks  

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

by Anonymous Monk
on May 04, 2006 at 08:35 UTC ( #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
Node Status?
node history
Node Type: note [id://547402]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others avoiding work at the Monastery: (2)
As of 2021-01-19 03:02 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Notices?