Beefy Boxes and Bandwidth Generously Provided by pair Networks
Keep It Simple, Stupid
 
PerlMonks  

Re: Join 2 arrays horizontally

by rsFalse (Hermit)
on Mar 04, 2019 at 08:29 UTC ( #1230822=note: print w/replies, xml ) Need Help??


in reply to Join 2 arrays horizontally

Some more variants:
#!/usr/bin/perl use strict; use warnings; my @array1 = qw(host1 host2 host3); my @array2 = qw(ip1 ip2 ip3); my $length1 = scalar @array1; # Asking for 2 elements of a list which is composed of elements from 2 + arrays print map "$_\n", map { join ': ', ( @array1, @array2 )[ $_, $_ + $length1 ] } 0 .. $length1 - 1; # Asking for elements of 2 arrays by using references for my $i ( 0 .. $length1 - 1 ){ print map "$_,\n", join ' --> ', map { $_->[ $i ] } \@array1, \@ar +ray2; }

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others making s'mores by the fire in the courtyard of the Monastery: (5)
As of 2020-01-28 06:21 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Notices?