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:

1 2 3 1 2 3 1 2 3 blue white yellow blue white yellow blue white yellow
I know this code is not ideal, but my goal here is to make a output print as I mentioned. Any ideas? Thanks!


In reply to issue with print/join 2 arrays by juanito23

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.