my @array = (1,2,5..20,42..99); my %element; @element{@array} = (); print exists $element{$num}? "$num found": "$num not found";