Perl Monk, Perl Meditation | |
PerlMonks |
Re: Different result for 'foreach' vs 'while shift' arrayrefby tobyink (Canon) |
on Apr 18, 2014 at 09:17 UTC ( [id://1082734]=note: print w/replies, xml ) | Need Help?? |
With this one:
If @$rowcache contains a false value (e.g. undef, or the empty string, or the number 0), then when that value is reached, the condition will become false, so the while loop will exit. If you really want to use while, then you could do:
Or, if you know that @$rowcache consists of only defined values (no undefs, but perhaps some empty strings and zeros), you could do:
use Moops; class Cow :rw { has name => (default => 'Ermintrude') }; say Cow->new->name
In Section
Seekers of Perl Wisdom
|
|