Beefy Boxes and Bandwidth Generously Provided by pair Networks
Don't ask to ask, just ask
 
PerlMonks  

Re: Perl For loops

by Util (Priest)
on Jul 03, 2007 at 21:08 UTC ( [id://624787]=note: print w/replies, xml ) Need Help??


in reply to Perl For loops

Untested, and probably *completely* wrong due to lack of <CODE>...</CODE> tags in the OP:

my @matrix = ( [ qw( 1 2 4 4 ) ], [ qw( 5 2 0 8 ) ], [ qw( 9 10 11 12 ) ], ); my @t; foreach my $column_num ( 0 .. $#{ $matrix[0] } ) { my @slice = map { $_->[$column_num] } @matrix; my @r; foreach my $n ( @slice ) { last if $n == 0; push @r, $n; } push @t, [@r]; }

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others taking refuge in the Monastery: (4)
As of 2024-03-29 10:10 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found