No, the loop won't exit even if [ undef ] or [ 0 ] is returned. List assignment in scalar context returns the number of elements to which its RHS evaluates, meaning the number of elements in the array.
You'd be right that
while( my $next = $iter->() ) {
my @next = @$next;
...
}
is not equivalent to
while( my @next = @{ $iter->() } ) {
...
}
But that's not the situation here.
The point was that
while( my $next = $iter->() ) {
($next) = @$next;
...
}
is a complicated version of
while( my $next = @{ $iter->() } ) {
...
}
which is just an expensive version of
while( my ($next) = $iter->() ) {
...
}
|