use Benchmark qw/timethese/; use strict; use warnings; my $array = [1..10000]; timethese(10000, {"straight" => sub {straight($array)}, "flatten" => sub {flatten(@$array)}}); sub straight { ; } sub flatten { ; }