perlquestion
perlnoobster
Hi Gurus,
I have the following coding which loops to assign a phone model to a colour:
<code>
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)
}
</code>
in the phones.txt file there is a list of phones such as:
<code>
iphone
samsung s2
motoroalla atrix
</code>
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) $results[1] = phone style (column 2)
I hope this makes sense? please can someone help me?
Thank you :)