Beefy Boxes and Bandwidth Generously Provided by pair Networks
go ahead... be a heretic

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?

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

How do I use this? | Other CB clients
Other Users?
Others rifling through the Monastery: (7)
As of 2015-11-29 20:12 GMT
Find Nodes?
    Voting Booth?

    What would be the most significant thing to happen if a rope (or wire) tied the Earth and the Moon together?

    Results (753 votes), past polls