[plug] Perl Question

David Buddrige buddrige at wasp.net.au
Tue May 13 13:51:17 WST 2003


Hi all, 

I have a comma-delimited text file containing records, with one line per
record.  The fields are seperated by commas 

For example, one line from the text file is: 

543,XB5435,0000043,ONSHORE SYSTEM (OS),CLD,Drawing,5/11/95,CX453 

What I want to do is to get each of these data items into a seperate
variable so that I can then output each field in the required manner 

My code thus far is: 


while(<>)
{
 my $line_to_parse = $_;
 # some code to parse the line 

 # then some code to output each field individually...
} 

where the program would be run in the following way: 


./myconverter.pl < mydatafile.txt > myoutputfile.txt 

My question: Is there a simple perl function that will pull out each field
value into a variable of some kind (I guess an array would be easiest),
where each value is seperatly accessible? 

thanks heaps guys 

David. 8-)



More information about the plug mailing list