#input = $search foreach my $key (keys %hash) { $searchline = $hash{$key}; if ($searchline =~ /$search/gi) { $contains ++; } }