Beefy Boxes and Bandwidth Generously Provided by pair Networks
Clear questions and runnable code
get the best and fastest answer
 
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 all is quiet...

How do I use this? | Other CB clients
Other Users?
Others taking refuge in the Monastery: (6)
As of 2017-02-27 19:27 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Before electricity was invented, what was the Electric Eel called?






    Results (392 votes). Check out past polls.