Hi Gurus, I have the following coding which loops to assign a phone model to a colour:
my $output = "phones_out.txt"; open(OUT,"+>$output"); my $PHONE_FILE = $ARGV[0] || 'phones.txt'; my @COLOURS = <DATA>; my $GET_MODEL = qr{\A ( [^\n]+ ) }x; open my $PHONES, '<', $PHONE_FILE or die "Cannot open $PHONE_FILE\n"; Case Cover"; while (my ($phn) = <$PHONES> =~ $GET_MODEL) { Do something (matches phone models to colours) }
in the phones.txt file there is a list of phones such as:
iphone samsung s2 motoroalla atrix
etc And the code runs perfectly fine, the colours in the __DATA__ section asign perfectly with the phone models. with all the above in mind I need help in regards to adding a second column into the phones.txt file, i added a column with values (seperated by tab) into the text file however that is also getting printed in the output file aswell as the first column? I want to differentiate between the columns at the beginning of the loop, is this possible? (so that i can call upon the variable at a later stage e.g $results[0] = phone model (column 1) $results1 = phone style (column 2) I hope this makes sense? please can someone help me? Thank you :)

In reply to Separate column 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.