in reply to Unconventional exit from while loop
I prefer clear stop values...
For instance
while( my ( $z, $y, $x, $w ) = @{ $iter->next // last } ) { }
is terminated for
but
while( my ($a_permutation) = $iter->next ) { ... }
is only terminated in the first case. You still have the liberty to return undef or [] as valid values.
In your special snippet undef or [] don't make much sense, but this approach helps avoiding quirks like 0 but true !
Anyway I wonder why the iterator was designed to return an array reference...
Why not right away returning a list?
while( my @permutation = $iter->next ) { ... }
Cheers Rolf
( addicted to the Perl Programming Language)
|
|---|