Beefy Boxes and Bandwidth Generously Provided by pair Networks
Just another Perl shrine
 
PerlMonks  

Re^2: Query of multi dimensional array

by shabird (Sexton)
on Mar 26, 2020 at 12:41 UTC ( [id://11114670]=note: print w/replies, xml ) Need Help??


in reply to Re: Query of multi dimensional array
in thread Query of multi dimentional array

Unfortunately your solution isn't printing anything to the terminal :(

Replies are listed 'Best First'.
Re^3: Query of multi dimensional array
by hippo (Bishop) on Mar 26, 2020 at 13:37 UTC

    Sure it does:

    $ 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. $

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others examining the Monastery: (8)
As of 2024-04-18 03:24 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found