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
In reply to Re: average of column
by BillKSmith
in thread average of column
by linseyr
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |