Beefy Boxes and Bandwidth Generously Provided by pair Networks
The stupid question is the question not asked
 
PerlMonks  

Re: How can you make this script general?

by llancet (Friar)
on Mar 10, 2014 at 09:34 UTC ( [id://1077663]=note: print w/replies, xml ) Need Help??


in reply to How can you make this script general?

You should notice that Perl arrays are autovivified, where if you use an index out of range, the array will be auto-expanded.

So what you need is: use an array to record the sum of columns. each time you read a line, and add the columns to the sum array.

my @sum; while (<FH>) { chomp; my @F = split /\t/; $sum[$_] += $F[$_] for 0..@F-1; }

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others sharing their wisdom with the Monastery: (2)
As of 2024-04-20 03:54 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found