Beefy Boxes and Bandwidth Generously Provided by pair Networks
Don't ask to ask, just ask

Re: averages from multiple files

by aaron_baugher (Curate)
on Nov 25, 2011 at 15:53 UTC ( #940093=note: print w/replies, xml ) Need Help??

in reply to averages from multiple files

Well, the first step in determining if a program is correct is to run it and see what happens. Since you were wise enough to use strict (part of Modern::Perl), yours will generate a syntax error. Fix that, run it again, fix the next one, repeat until the program runs. Then you can start to worry about whether it generates the right results.

Just looking at it, the first thing that jumps out (other than s/spilt/split/) is that assigning a block to an array doesn't do anything like what you think it'll do. Saying my @file1 = { some_code_here } will (try to) take the results of some_code_here, create a hash from them, and assign a reference to that hash to the first element of @file1.

Since you want to go through the files line-by-line, look into the while loop for that. Start a while loop like while(<FILE1>){ and put your line processing stuff inside that. Once you get that working, figure out how to wrap your while loop inside a for loop, so you can put your input filenames in an array and not have to hardcode a separate while loop for each one.

Aaron B.
My Woefully Neglected Blog, where I occasionally mention Perl.

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://940093]
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others romping around the Monastery: (4)
As of 2018-04-25 03:57 GMT
Find Nodes?
    Voting Booth?