Beefy Boxes and Bandwidth Generously Provided by pair Networks
Think about Loose Coupling

Re: How can I print out part of the matrix

by mfriedman (Monk)
on Jun 02, 2002 at 20:44 UTC ( #171063=note: print w/replies, xml ) Need Help??

in reply to How can I print out part of the matrix

How are you building your matrix? If you're using an array of arrays, simply loop through the outer array and print the data in the inner array:

#!/usr/bin/perl -w use strict; my @aoa = get_data; foreach my $row(@aoa) { print "$row->[$_] " for (1, 2, 3, 5, 9, 10, 38, 126); print "\n"; }

If you don't know what columns you need to print ahead of time, build an array of the indices you need and use

print "$row->[$_] " for @indices;


Replies are listed 'Best First'.
Re: How can I print out part of the matrix
by Abigail-II (Bishop) on Jun 03, 2002 at 10:47 UTC
    But that means you're making many calls to print. Why not just:
    print "@{$_}[1, 2, 3, 5, 9, 10, 38, 126]\n" for @aoa;


Log In?

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

How do I use this? | Other CB clients
Other Users?
Others surveying the Monastery: (3)
As of 2021-06-13 17:45 GMT
Find Nodes?
    Voting Booth?
    What does the "s" stand for in "perls"? (Whence perls)

    Results (57 votes). Check out past polls.