my @match = grep { $_ =~ /($pattern)/ ; $hash{$_}{$pattern} = no_of_occurance_of_regex; } @inputs;