note
LanX
in <c>my $x = 10;</c> the <c>=</c> is a scalar assignment which returns the assigned scalar<P>
in <c>my ($y) = 10;</c> the <c>=</c> is a list assignment which returns the number of assigned elements¹<P>
That's a crucial trick for iterators, where returned elements might be false (like 0 , '' or undef).<P>
So
<c>while ( ($x) = iterator() ) {
...
} </c> will work as long as anything (i.e. no empty list) is returned, while <c>
while ( $x = iterator() ) {
...
}
</c> can break if you don't use special magics like "0 but true".<P>
<!-- Node text goes above. Div tags should contain sig only -->
<div class="pmsig"><div class="pmsig-708738">
<p>Cheers Rolf
</div></div><P>
UPDATE:<P>
1) in scalar context!
875693
875693