Beefy Boxes and Bandwidth Generously Provided by pair Networks
laziness, impatience, and hubris
 
PerlMonks  

Re: Why does a full iteration over array & shift is not emptying the array

by rubasov (Friar)
on May 04, 2010 at 14:26 UTC ( #838318=note: print w/ replies, xml ) Need Help??


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

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://838318]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others contemplating the Monastery: (14)
As of 2014-07-14 15:39 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    When choosing user names for websites, I prefer to use:








    Results (265 votes), past polls