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:  <%-{-{-{-<