in reply to Join 2 arrays horizontally

Hi there, it would be good to see what you have tried.

If you know the arrays are always going to have an equal number of elements, you can use the length to create a numeric range then loop through that range, using the numbers as indexes to get an element from each array.

for my $i ( 0 .. $#array1 ) { say join ' ', $array2[$i], $array1[$i]; }

There are a plethora of other ways, many more idiomatic. But this should get you started figuring out the concepts.

Hope that helps!


The way forward always starts with a minimal test.

Replies are listed 'Best First'.
Re^2: Join 2 arrays horizontally
by perl_5eeker (Novice) on Mar 03, 2019 at 23:59 UTC

    Awesome, thanks for the help - got me going!!