use strict; use warnings; use Benchmark("timethese"); my $array; for (1 .. 100_000) { push @$array, $_; } my $hash; for (1 .. 100_000) { $hash->{$_} = 1; } timethese(1, {'array' => sub {s1($array)}, 'hash' => sub{s2($hash)}}); sub s1 { my $array = shift; for (my $i = 100_000; $i > 0; $i --) { splice(@$array, int(rand($i)), 1); } } sub s2 { my $hash = shift; for (my $i = 100_000; $i > 0; $i --) { delete($hash->{int(rand($i))}); } }