$ cat bio.pl
#!/usr/bin/env perl
use strict;
use warnings;
my @myArray;
while (<DATA>) {
my @columns = split /\s+/, $_;
push @myArray, \@columns;
}
my $title_row = shift @myArray;
for my $row (@myArray) {
my $sum = 0;
for my $col (1 .. $#$row) {
$sum += $row->[$col];
}
print "$row->[0] $sum\n";
}
__DATA__
GeneID Tp1 Tp2 Tp3
ALA1 10 12 11
THR8 57 99 12
HUA4 100 177 199
ABA5 2 5 10
$ ./bio.pl
ALA1 33
THR8 168
HUA4 476
ABA5 17
$ perl -v
This is perl 5, version 20, subversion 3 (v5.20.3) built for x86_64-li
+nux-thread-multi
(with 16 registered patches, see perl -V for more detail)
Copyright 1987-2015, Larry Wall
Perl may be copied only under the terms of either the Artistic License
+ or the
GNU General Public License, which may be found in the Perl 5 source ki
+t.
Complete documentation for Perl, including FAQ lists, should be found
+on
this system using "man perl" or "perldoc perl". If you have access to
+ the
Internet, point your browser at http://www.perl.org/, the Perl Home Pa
+ge.
$
|