in reply to Hash reference searching

The right way for hash ref is:

if( exists $HASH_REF->{$random_number} ){;}

Also use Benchmark; for such tasks.