Beefy Boxes and Bandwidth Generously Provided by pair Networks
"be consistent"
 
PerlMonks  

Re: build multidimensional array from arrays (mapcar)

by tye (Sage)
on Jan 29, 2004 at 19:56 UTC ( #325020=note: print w/replies, xml ) Need Help??


in reply to build multidimensional array from arrays

You can also use mapcar (such as from Algorithm::Loops) to avoid indexing:

use Algorithm::Loops qw( MapCarE ); my @one = qw( A B C D ); my @two = qw( E F G H ); my @tre = qw( W X Y Z );
my @mda = MapCarE { [@_] } \( @one, @two, @tre );
require Data::Dumper; print Data::Dumper->new([\@mda],['@mda']) ->Indent(1)->Terse(1)->Dump();
produces
[ [ 'A', 'E', 'W' ], [ 'B', 'F', 'X' ], [ 'C', 'G', 'Y' ], [ 'D', 'H', 'Z' ] ]

- tye        

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others meditating upon the Monastery: (3)
As of 2019-07-20 05:04 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found

    Notices?