Beefy Boxes and Bandwidth Generously Provided by pair Networks
good chemistry is complicated,
and a little bit messy -LW
 
PerlMonks  

Re: Rookie question

by Athanasius (Chancellor)
on Oct 18, 2012 at 02:57 UTC ( #999659=note: print w/replies, xml ) Need Help??


in reply to Rook question

Hello squimby, and welcome to the Monastery!

Any tips for 'Perl'ifying this?

Building on NetWallah’s answer:

sub total { my $sum = shift; $sum += $_ for @_; return $sum; }

See shift and Statement Modifiers.

Update: Also read-up on $_ in General Variables.

Hope that helps,

Athanasius <°(((><contra mundum

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://999659]
help
Chatterbox?
and John Coltrane plays...

How do I use this? | Other CB clients
Other Users?
Others contemplating the Monastery: (7)
As of 2017-11-21 00:10 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    In order to be able to say "I know Perl", you must have:













    Results (294 votes). Check out past polls.

    Notices?