Beefy Boxes and Bandwidth Generously Provided by pair Networks
P is for Practical
 
PerlMonks  

Re: build multidimensional array from arrays (mapcar)

by tye (Sage)
on Jan 29, 2004 at 19:56 UTC ( [id://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
Domain Nodelet?
Node Status?
node history
Node Type: note [id://325020]
help
Chatterbox?
and the web crawler heard nothing...

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

    No recent polls found