Beefy Boxes and Bandwidth Generously Provided by pair Networks
We don't bite newbies here... much
 
PerlMonks  

Re: Join 2 arrays horizontally

by jwkrahn (Abbot)
on Mar 03, 2019 at 23:52 UTC ( [id://1230813]=note: print w/replies, xml ) Need Help??


in reply to Join 2 arrays horizontally

Try List::MoreUtils pairwise function: (UNTESTED)

use List::MoreUtils 'pairwise'; @array1 = qw(host1 host2 host3); @array2 = qw(ip1 ip2 ip3); my @result = pairwise { "$b $a" } @array1, @array2;

Replies are listed 'Best First'.
Re^2: Join 2 arrays horizontally
by AnomalousMonk (Archbishop) on Mar 04, 2019 at 02:24 UTC

    I was thinking  each_array() myself. Assume all arrays are the same size:

    c:\@Work\Perl\monks>perl -wMstrict -le "use List::MoreUtils qw(each_array); ;; my @array1 = qw(host1 host2 host3); my @array2 = qw(ip1 ip2 ip3); my $ea = each_array(@array2, @array1); ;; while (my @ra = $ea->()) { print qq{:@ra:}; } " :ip1 host1: :ip2 host2: :ip3 host3:
    See List::MoreUtils.


    Give a man a fish:  <%-{-{-{-<

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others romping around the Monastery: (2)
As of 2024-04-26 03:53 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found