in reply to Grep reutrn the occurance of a pattern

Hi all,

I am the one who ask the question in rush, Thanks all of you answer this poorly organized question. After certain period of time and read the reply, I think I prefer something like this....

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

So I wil get a hash with the thing I want. Does it possible in grep?