Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl-Sensitive Sunglasses
 
PerlMonks  

Re^3: Help with arrays

by Rohit Jain (Sexton)
on Sep 22, 2012 at 05:55 UTC ( #995049=note: print w/ replies, xml ) Need Help??


in reply to Re^2: Help with arrays
in thread Help with arrays

You can use shift operator in this case..

shift operator takes an array, removes an element from the start and updates the existing array

If your array becomes empty, it returns undef, which you can handle

sub average { $sum = shift @_; while (defined($num = shift @_)) { $sum += $num; } }
Comment on Re^3: Help with arrays
Download Code

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others drinking their drinks and smoking their pipes about the Monastery: (4)
As of 2016-04-30 16:31 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    :nehw tseb si esrever ni gnitirW







    Results (441 votes). Check out past polls.