perlnoobster has asked for the wisdom of the Perl Monks concerning the following question:
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:Please can someone help me? Thank you :){ 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" }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Split array and join with results
by cheekuperl (Monk) on Aug 22, 2012 at 14:59 UTC | |
by perlnoobster (Sexton) on Aug 22, 2012 at 15:07 UTC | |
by perlnoobster (Sexton) on Aug 22, 2012 at 15:15 UTC | |
by cheekuperl (Monk) on Aug 22, 2012 at 16:00 UTC | |
|
Re: Split array and join with results
by BillKSmith (Monsignor) on Aug 22, 2012 at 20:30 UTC | |
by perlnoobster (Sexton) on Aug 22, 2012 at 21:02 UTC | |
by BillKSmith (Monsignor) on Aug 23, 2012 at 04:01 UTC | |
by perlnoobster (Sexton) on Aug 23, 2012 at 10:51 UTC | |
by BillKSmith (Monsignor) on Aug 23, 2012 at 17:42 UTC | |
|