in reply to Hits on a reg expression

Read Perl Idioms Explained - @ary = $str =~ m/(stuff)/g. All you have to do then is to get $#ary+1.