in reply to RE: Re: is split optimized?
in thread is split optimized?
I answered Anonymous Monks's question of wether "perl optimize(s) the split and only grab the first field" with the line: ($y) = (split(/\s+/,$x))[0]; To which the answer is no. But as I conceeded to btrott, he (and nardo) had the "correct" answer, of saying that you need to add a third arguement to get split to only do the first match.
Appreciately, you probably responded because I used regex's in my example and you did not want Anonymous Monk to mistakenly think that regex's were faster than split. However I do not think he took it that way, rather his post seemed to convey an understanding of all of what I just mentioned above (minus the fact that we did not know/remember about the third arguement in split).
Anyway, this is mainly here to clear up the comment in the chatterbox about benchmark being a hammer. I was only using it to show, fairly concretely, that split was not stopping after the first match. I didn't mean to imply that it couldn't.
Cheers,
Gryn
|
|---|