I need to read from a file and be able to split it into columns and ignore a line if it starts with ' . '.
the text file is made of 3 columns but at some lines there are no words in the first column
here is an example of the text file
BANANAS ARE YELLOW
CHEESE IS YELLOW
IS BLUE
IS WHITE
JENNY LIKES PERL
. Line WITH a dot
Also i want to be able to ignore the line that starts with the " . "
thats just a close example of what the file looks like
basically i want to split after reading the file into 3 arrays, the first array having the contents of the first column, the second array having the contents of the second column and so forth. Here is my implementation . i have not used chomp yet
#!/usr/bin/perl
open (nastyfile , "file.txt");
my @lines = <nastyfile>;
foreach $word (@lines)
{
(@col1,@col2,@col3)= split (/t/,$word);
print "@col1";
}
print @lines;
close (nastyfile);
so basically i want the first array to have the words bananas cheese and jenny