From perldoc, in perldata, there is a line of code like:
$count = () = $string =~ /\d+/g;
It says $count will be set to the number of matches because assigning to the bracket means assigning to the empty list and it converts to list context. But when I do:
print (() = $string =~ /\d+/g);
I was expecting to print an array of matches but it prints nothing. If the empty list is nothing, how does the previous assignment from () to $count works? What does the first one mean by assigning to empty list and what does it actually do?
More specifically,
print $string =~ /\d+/g; #print all matches
print (() = $string =~ /\d+/g); #print nothing (why)
print ($count = () = $string =~ /\d+/g); #print number of matches (why again)