| Next | Making Programs Faster | 99 |
Newsgroups: comp.lang.perl.misc
Date: Wed, 10 Oct 2001 18:59:17 +0400
Message-ID: <3BC46245.E2B3630A@pisem.net>
Suppose we have $_="haha:lala:rere";
What is faster??
($haha) = split /:/, $_; # or
($haha) = split(/:/, $_, 1);
Lots of people weighed in on this matter
Some advised the use of Benchmark
Few noticed that the two samples do not do the same thing
Or that the second sample is entirely worthless
# $_ = "a:b:c:d"
split /:/, $_, 3; # ("a", "b", "c:d")
split /:/, $_, 2; # ("a", "b:c:d")
split /:/, $_, 1; # ("a:b:c:d")
($haha) = split /:/, $_; # ("a", "b:c:d")
| Next | ![]() |
Copyright © 2003 M. J. Dominus |