List assignment in a scalar context returns the number of items in the right-hand side because that is extremely useful as a Boolean test, as shown in your own example:
while( my( $k, $v ) = each %h ) {
You wouldn't want that loop to terminate early just because one of the values in %h was false.
- tye
In reply to Re: list assignment to list in scalar context (boolean)
by tye
in thread list assignment to list in scalar context
by Anonymous Monk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |