Beefy Boxes and Bandwidth Generously Provided by pair Networks
laziness, impatience, and hubris
 
PerlMonks  

Re: average of column

by BillKSmith (Priest)
on Sep 12, 2012 at 16:24 UTC ( #993248=note: print w/replies, xml ) Need Help??


in reply to average of column

I like toolic's solution, but if you prefer not to use a module:

use strict; use warnings; my $sum; my $count; while (<DATA>) { my $length = (split)[3]; next if $length eq 'length'; $count++; $sum += $length; } my $average_length = $sum/$count; print $average_length, "\n"; __DATA__ chr start end length chr1 10 50 40 chr2 20 80 60
Bill

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://993248]
help
Chatterbox?
[erix]: I guess I can pass for a native
[LanX]: talking about destruction of diving spots
[LanX]: Nodes to consider
[erix]: oops - got to run, see you later
[robby_dobby]: erix: 'appy day'ving

How do I use this? | Other CB clients
Other Users?
Others chilling in the Monastery: (12)
As of 2017-04-24 16:24 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    I'm a fool:











    Results (442 votes). Check out past polls.