in reply to Re: Counting multiple matches of RegExp in single line
in thread Counting multiple matches of RegExp in single line

If you mean the parens in the regex, you don't need them using the other way, either. /PAT/g in list context, will imply parens around the whole match, if none are provided in the pattern.
$count = () = $teststring =~ /test/g;
will just work fine.

This is documented in perlop, see the last sentence in this paragraph:

The "/g" modifier specifies global pattern matching--that is, matching as many times as possible within the string. How it behaves depends on the context. In list context, it returns a list of the substrings matched by any capturing parentheses in the regular expression. If there are no parentheses, it returns a list of all the matched strings, as if there were parentheses around the whole pattern.

Replies are listed 'Best First'.
Re^3: Counting multiple matches of RegExp in single line
by gaal (Parson) on Nov 27, 2004 at 13:28 UTC
    Hey, good stuff, thanks for the tip.