@hash{@array} = (); #### #!/usr/bin/perl -w use strict; use Benchmark; sub is_elem_of_A { my ($x, %hash) = shift; @hash{@_} = (1) x @_; exists $hash{$x} } sub is_elem_of_B { my ($x, %hash) = shift; @hash{@_} = (); exists $hash{$x} } my %param = ( short => [ qw(one one two three four five) ], long => [ 10, 1 .. 10000 ], ); for(qw(short long)) { print "Timing with $_ list\n"; my $list = $param{$_}; timethese -5, { xop => sub{ is_elem_of_A @$list }, emptylist => sub{ is_elem_of_B @$list }, }; } __END__ Timing with short list Benchmark: running emptylist, xop, each for at least 5 CPU seconds... emptylist: 6 wallclock secs ( 5.29 usr + 0.04 sys = 5.33 CPU) @ 42362.48/s (n=225792) xop: 6 wallclock secs ( 5.35 usr + 0.04 sys = 5.39 CPU) @ 31733.58/s (n=171044) Timing with long list Benchmark: running emptylist, xop, each for at least 5 CPU seconds... emptylist: 5 wallclock secs ( 5.28 usr + 0.01 sys = 5.29 CPU) @ 22.12/s (n=117) xop: 6 wallclock secs ( 5.50 usr + 0.02 sys = 5.52 CPU) @ 15.40/s (n=85)