in reply to Grep reutrn the occurance of a pattern

You can count the occurances and retain the captures like this. I'm not sure what you mean by "the index of an array for a pattern" though. Perhaps you could elaborate. This

$ perl -le ' > $str = q{adasdGTsaJsdfsCFwee}; > $capsCt = @caps = $str =~ m{([A-Z]+)}; > print qq{Found: $capsCt}; > print for @caps;'

produces

Found: 3 GT J CF

I hope this is helpful.

Cheers,

JohnGG