In scalar context m//g doesn't return size of the list it would give back when called in list context,
If you want the number of elements in the list returned by a pattern with the /g modifier when evaluated in list context, you can use a list assignment in scalar context, which produces the number of its elements. In this case, we assign to an empty list:
$_ = "456"; $count = () = /./g; print $count; # prints 3
In reply to Re: m//g behaves strange...
by converter
in thread m//g behaves strange...
by Anonymous Monk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |