my @list = (10,11,12,13,14,15,17,18,22,23,24,25,26,27,28,29,30,31,32,33,34,35 ); my %hash; @hash{@list} = (1) x @list; # This solution only makes sense if you're # making the comparison multiple times foreach my $x (1..1000) { if ($hash{$x}) { print "$x is in the list\n"; } }