my $text = 'foxcub ' x 1000; my @matches = $text =~ m/fox(\w+)/g; my $count = scalar @matches; print join(', ', @matches);