Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl Monk, Perl Meditation
 
PerlMonks  

Re: sumof - attempting to sum a column from each file

by roboticus (Canon)
on Sep 14, 2012 at 15:53 UTC ( #993747=note: print w/ replies, xml ) Need Help??


in reply to sumof - attempting to sum a column from each file

ricky5ive:

You're setting your count to 0 after each line read. You want to do it only once per file. So move the my $sumof=0; to just before or after the open statement.

You're also summing up the items *while you're still reading the file*. Finish reading the lines before doing the summing operation.

...roboticus

When your only tool is a hammer, all problems look like your thumb.


Comment on Re: sumof - attempting to sum a column from each file
Download Code

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others making s'mores by the fire in the courtyard of the Monastery: (5)
As of 2014-08-01 23:52 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    Who would be the most fun to work for?















    Results (53 votes), past polls