http://www.perlmonks.org?node_id=838318


in reply to Why does a full iteration over array & shift is not emptying the array

Another way to do it (this won't fail if your array contains undefs):
my @a = ( 1 .. 4, undef, 6 .. 10 ); while (@a) { my $x = shift @a; say defined $x ? $x : 'undef'; }
  • Comment on Re: Why does a full iteration over array & shift is not emptying the array
  • Download Code