Home: Perl Programming Help: Beginner:
Assigning arrays to columns in a file?



AndrewF
Novice

Jul 18, 2013, 4:31 PM


Views: 1981
Assigning arrays to columns in a file?

Hello there, Ive been stuck trying to assign two different arrays I have to two different columns in a file. [/codeopen (ECFILE, 'PEC,CEC.txt');

my @reactant;
my @product;

while (<ECFILE>){

my @all = <ECFILE>;
push (@reactant, $all[0]);
push (@product, $all[1]);
print "@reactant\n";
print "@product\n";
}]

the file is formatted like so...
AA AA
AB AB
AC AC
AD AD
Any help? I know Im close to the answer but I've been looking at this for awhile and need another set of eyes to catch what I've missed. Thanks very much!