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

Re: average of column

by pvaldes (Chaplain)
on Sep 12, 2012 at 18:18 UTC ( #993276=note: print w/ replies, xml ) Need Help??


in reply to average of column

Arg, that's very similar to the other solutions but not so elegant. Well... another way to skin this cat

#!/usr/bin/perl use strict; use warnings; use List::Util qw(sum); my @array = (); while (<DATA>) { next if /start/; chomp; my (undef,undef,undef,$col4,undef) = split (/\s*/, $_,5); push (@array, $col4); } my $sum = sum(@array); print $sum,"\/"; my $n = scalar(@array); print $n,"\n"; print "average = ", $sum/$n,"\n"; __DATA__ chr start end length foo e r t 6 r 4 A 6 4 f 4 3 4 5 f L 0 L 2 f 0 0 0 1 0 3 4 5 6 7


Comment on Re: average of column
Download Code

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others cooling their heels in the Monastery: (6)
As of 2014-09-23 21:12 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    How do you remember the number of days in each month?











    Results (241 votes), past polls