my %hash; @hash{@list} = (); # Don't bother filling in values foreach my $x (1..1000) { if (exists $hash{$x}) # Just test for existence of key { print "$x is in the list\n"; } }