I have a text file with five colums of data (ColumA-E). Within each column there could be multiple data with a comma seperating each piece of data. How do i white a loop to parse through the data set and assign each column a variable and each piece of data within that column a different variable?
I haven't done much coding on this yet but here's the idea: test.txt: ColumA|ColumB|ColumC|ColumD|ColumE Test|A,F|ACY,FAC|ACYA,FCSA,FCSC|ACYEA,FCSA2 Test2|A|A1,A2,A3,A4,A5,A6|B1,B2|C1,C2,C3 Test3|B|b10,B11,B12,B13,|C1,C2| #!/usr/bin/perl use strict; use warnings; my $File = 'test.txt'; my $output = 'ouput.txt'; open FILE, '<', $File or die "Could not open open OUT, '>', $output or die "Could not open '$output' $!"; '$File' $!"; while ( <File> ) { next if $. == 1; # exclude header chomp; my ( $ColA, $ColB, $ColC, $ColD,$ColE ) = split /\|/; #Note: should i assign the different data elements inside of each # $ColA, $ColB,etc. into an array here? #For example, I want to split ColC of the first row in test.txt #into different variables so that i can assign different variables names #to each of the data within that colum...i.e. $ColD_1=ACYA, #$ColD_2=FCSA...etc. What i want to do is print each variable out into a text #file (output.txt) }; } close FILE; print OUT; __END__ Thanks for any suggestions. --------------------------------- Never miss a thing. Make Yahoo your homepage.