my %hash; @hash{@array} = (); ## or @hash{@array} = (1) x @array; if (exists $hash{$scalar}) { ## Matched. }