Beefy Boxes and Bandwidth Generously Provided by pair Networks
There's more than one way to do things
 
PerlMonks  

Re: average of column

by BillKSmith (Vicar)
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?
[corenth]: @stuff was pretty big. I think it grew to about 8000.
[corenth]: each element was several three + element references
[corenth]: That FANN thing sounds like something I
[Cosmic37]: When I say I like LGPL what I mean is that I like the GPL aspect. I am a fan of Rishard Stallman and the Free Software Foundation but I wish I could be more virtuous... self-flagellates
[corenth]: . . . I'd like to play with
[corenth]: I'm a pragmatic free-software advocate. I'll play in a walled sandbox when I need to.
[erix]: hm, there's a FANN perl module - looks a bit old
[Cosmic37]: I'm afraid I don't know the answer to your map question...... what were the references too?
[corenth]: each reference was to a fairly small scaler.

How do I use this? | Other CB clients
Other Users?
Others cooling their heels in the Monastery: (6)
As of 2018-02-20 18:26 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    When it is dark outside I am happiest to see ...














    Results (274 votes). Check out past polls.

    Notices?