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