Hi Perl monks, i'm a noob to perl and need assistance with the following dilemma, I have a list of words being read from a text file and I have an array of colours that I wish to assign to each word. The text file contains the following: iphone 3 iphone 3gs iphone 4 the array contains colours such as red blue green all i require is an output file showing the following: iphone 3 red iphone 3 blue iphone 3 green iphone 3gs red iphone 3gs blue iphone 3gs green iphone 4 red iphone 4 blue iphone 4 green

here's the coding for the array so far:
{ no warnings 'uninitialized'; chomp $results; push (@oid,$results[0]); $_ = defined($_) ? $_ : '' for @results; print "\n$results"; my $colour=(); my @colours=(); @colours = ( "baby blue", "baby pink", "black", "dark blue", "brown", + "dark purple", "green", "orange", "hot pink", "light purple", "red", + "white", "yellow"); foreach $colour (@colours) { print $colour; } print OUT "$results$colour\n" }
Please can someone help me? Thank you :)

In reply to Split array and join with results by perlnoobster

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.