juanito23 has asked for the wisdom of the Perl Monks concerning the following question:
Hi, I am struggling with an issue with printing 2 arrays. Let's say I have these 2 arrays:
@array1 = [1, 2, 3, 1, 2, 3, 1, 2, 3 ] @array2 = [blue, white, yellow, blue, white, yellow, blue, white, yell +ow]
IS there a way so I can have an output like
1 2 3 blue white yellow 1 2 3 blue white yellow 1 2 3 blue white yellow
so the idea would be printing 3 elements of each row and print them together. I can print wach array separated like this:
while (@array1){ push (@array_wb, $_[0]); push (@array_wb, $_[1] ); push (@array_wb, $_[2] . "\n"); push (@array_wb, $_[3]); push (@array_wb, $_[4] ); push (@array_wb, $_[5] . "\n"); push (@array_wb, $_[6]); push (@array_wb, $_[7] ); push (@array_wb, $_[8] . "\n"); print (@array_wb); }
So I can print both array separared, bue if I print both I get this:
I know this code is not ideal, but my goal here is to make a output print as I mentioned. Any ideas? Thanks!1 2 3 1 2 3 1 2 3 blue white yellow blue white yellow blue white yellow
Back to
Seekers of Perl Wisdom