in reply to Returning N values from a Regexp

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.