m// will return a list of matched (remembered) values if evaluated in list context. Your best bet would just be to gather the matches that way, then count them if you still need to.
my $text = 'foxcub ' x 1000; my @matches = $text =~ m/fox(\w+)/g; my $count = scalar @matches; print join(', ', @matches);
would print 'cub' 1000 times, in a comma-delimited list.
In reply to Re: Returning N values from a Regexp
by thpfft
in thread Returning N values from a Regexp
by Tanalis
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |