use strict; use warnings; use Benchmark qw(cmpthese); for my $argCount (2, 10, 100) { my @args = (1 .. $argCount); print "\nFor $argCount elements:\n"; cmpthese (-1, { hashArg => sub {noCopy ({@args})}, listArg => sub {noCopy (@args)}, toList => sub {toList (@args)}, toHash => sub {toHash (@args)}, } ); } sub noCopy { } sub toList { my @args = @_; } sub toHash { my %hash = @_; }