in reply to Re^2: Request help on optimizing a loop for looking up numbers
in thread Request help on optimizing a loop for looking up numbers

You can do something like

if (grep exists $hash{$_}, 7..12) {

but it's not necessarily any faster.

A hash is an unordered data type, so there's no easy way to search for a range. (There are some "ordered hash" packages on cpan, but that's really a misleading name.)