while(my ($key,$value)= each (%hash_table)) { while() { chomp; my ($objid,$other) = split(/\s+/,$_); if($objid =~ /$key/i) { print "$key is present in $objid\n"; } else { next; } } }