The () = puts the regex into list context, then the scalar assignment, as is usual, assigns the countof the items in the list.An array returns its weight, a list returns its last... a list in scalar context returns its last element, not the count of elements.
In reply to array and list return different things in scalar context
by metaperl
in thread How can I access the number of repititions in a regex?
by pat_mc
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |