my %test @test{@array} = (); foreach (@many_test_values) { if (exists $test{$_}) { # here is a match } }