Beefy Boxes and Bandwidth Generously Provided by pair Networks
Clear questions and runnable code
get the best and fastest answer
 
PerlMonks  

Re: Transpose a bi-dimensional array

by jmcnamara (Monsignor)
on Jul 21, 2003 at 11:29 UTC ( [id://276225]=note: print w/replies, xml ) Need Help??


in reply to Transpose a bi-dimensional array


Here is one way:
#!/usr/bin/perl -wl use strict; use Data::Dumper; my @matrix = ( [ qw(ab cd ef gh)], [ qw(ij kl mn op)], [ qw(qr st uv wx)] ); my @transpose; for my $aref (@matrix) { my $i = 0; push @{$transpose[$i++]}, $_ for @$aref; } print Dumper(@matrix); print Dumper(@transpose); __END__

--
John.

Replies are listed 'Best First'.
Re^2: Transpose a bi-dimensional array
by Anonymous Monk on Apr 02, 2016 at 19:21 UTC
    Hi John, How to print the data to the specific file instead of in terminal? Thanks Anil

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others making s'mores by the fire in the courtyard of the Monastery: (2)
As of 2024-04-16 20:36 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found