Perl's empty parentheses () idiom, is a list assignment in scalar context which returns the number of elements on the right-hand side of the list assignment.

() is very useful to count the number of matches in a regular expression

 

For example:

{code}
my $str = 'aa bb cccc';

my $val = () = $str =~ /\w+/g;

print $val;

{/code}

The above snippet will print number of matches in the regexp.