CGI/Perl Guide | Learning Center | Forums | Advertise | Login
Site Search: in

  Main Index MAIN
INDEX
Search Posts SEARCH
POSTS
Who's Online WHO'S
ONLINE
Log in LOG
IN

Home: Perl Programming Help: Beginner:
Adding all elements of array

 



burning_flag
New User

Apr 5, 2011, 9:35 PM

Post #1 of 2 (558 views)
Adding all elements of array Can't Post

I've been working on a script and this is my last hang-up. I need to add each element of an array together (# of elements in the array varies) and print the sum. I've been working on it for a while and I can't quite get this part right.

I'm quite new at perl scripting and I really just want to finish this script.. can anyone tell me how to get the sum of all elements of an array?


miller
User

Apr 5, 2011, 10:22 PM

Post #2 of 2 (555 views)
Re: [burning_flag] Adding all elements of array [In reply to] Can't Post

What have you tried thus far? Show your code and point out where you're having trouble, and someone will probably help you. However, this is a common homework problem, so people aren't just going to give you the solution.

Note: there is also List::Util if you're allowed to use core modules.

 
 


Search for (options) Powered by Gossamer Forum v.1.2.0

Web Applications & Managed Hosting Powered by Gossamer Threads
Visit our Mailing List Archives