squimby has asked for the wisdom of the Perl Monks concerning the following question:
So, I'm an utter noob learning Perl for work--and hopefully once I'm decent, to actually do things as well. Nonetheless, I'm trying to do an exercise in the O'Reilly camel book, but I can't get this subroutine working correctly:
Any help? It always adds up to 17 when I include it in a script which throws in any number of arguments. Also: I'm trying to be more 'Perl Zen' but my code above looks like it'd be best friends with the cold and rigid likes of C++ or Java. Any tips for 'Perl'ifying this?sub total{ my $sum = shift(@_); foreach (@_){ $sum += @_; }
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: Rook question
by NetWallah (Canon) on Oct 18, 2012 at 02:46 UTC | |
by squimby (Acolyte) on Oct 18, 2012 at 02:58 UTC | |
by davido (Cardinal) on Oct 18, 2012 at 03:09 UTC | |
by Anonymous Monk on Oct 18, 2012 at 03:10 UTC | |
Re: Rookie question
by Athanasius (Archbishop) on Oct 18, 2012 at 02:57 UTC | |
Re: Rook question
by sundialsvc4 (Abbot) on Oct 18, 2012 at 13:21 UTC | |
Re: Rook question
by blue_cowdawg (Monsignor) on Oct 18, 2012 at 13:35 UTC | |
by Anonymous Monk on Oct 18, 2012 at 17:18 UTC | |
by squimby (Acolyte) on Oct 19, 2012 at 00:40 UTC | |
by blue_cowdawg (Monsignor) on Oct 19, 2012 at 13:34 UTC | |
by Anonymous Monk on Oct 19, 2012 at 17:16 UTC |
Back to
Seekers of Perl Wisdom