use strict; use Benchmark qw/timethese cmpthese/; my $str = join ',',map{('a'..'z')[rand 26] x (1 + rand 5)}0..1000; cmpthese( timethese(10000, { 'split_anonymous' => '&split_anonymous', 'split_simple' => '&split_simple', }) ); sub split_anonymous { my $n = @{[split ',', $str]}; #print "$n\n"; } sub split_simple { my $n = scalar split ',', $str; #print "$n\n"; }