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

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 cooling their heels in the Monastery: (3)
As of 2017-10-19 04:57 GMT
Find Nodes?
    Voting Booth?
    My fridge is mostly full of:

    Results (251 votes). Check out past polls.