if( grep{$test eq $_} @array ){ # } #### foreach (@array) { next unless $_ eq $test; #here is a match # ... last; } #### my %test @test{@array} = (); foreach (@many_test_values) { if (exists $test{$_}) { # here is a match } }