in reply to Re: is split optimized?
in thread is split optimized?

well, according to the benchmark:
#!/usr/bin/perl -w use strict; use Benchmark; my $x = "a b c d e f g"; sub list_context { my $y = (split(/\s+/, $x))[0]; } sub extra_argument { my $y = (split(/\s+/, $x, 2))[0]; } timethese(-3, { "LIST CONTEXT" => \&list_context, "EXTRA ARGUMENT" => \&extra_argument, }); [ed@darkness ed]$ perl ./splittest.pl Benchmark: running EXTRA ARGUMENT, LIST CONTEXT, each for at least 3 C +PU seconds... EXTRA ARGUMENT: 2 wallclock secs ( 3.14 usr + 0.00 sys = 3.14 CPU) +@ 115563.69/s (n=362870) LIST CONTEXT: 3 wallclock secs ( 3.18 usr + 0.00 sys = 3.18 CPU) @ +57053.46/s (n=181430)
the extra argument version of split kicks the living crap out of not using it... so i guess, yes ;) it does make a difference!