Not tested
While (<file>){
my @record = split /\|/;
if ($record[6]){ #remember arrays start counting at zero
do what ever you want with the data here
}
}
HTH
Paul
-----Original Message-----
From: LoneWolf [mailto:[EMAIL PROTECTED]
Sent: Tuesday, September 16, 2003 10:42 AM
To: [EMAIL PROTECTED]
Subject: big switching...
I have a 12 field 3000 line file (| delimited) and need to check the 7th
entry of each line to see what it is, and based on that it needs to be
written out to a file with a new entry in the 7th spot. I could do it
with a few entries to check, but the permutation is of 253 different
choices.
Example:
data.txt
ww-a10991t|rolls|5765|365.3|385|12|RR|Rolls Royce|2|0|1|A
ww-a10991w|rolls|5763|365.3|385|12|RR|Rolls Royce|2|0|1|A
ww-a10991b|rolls|5790|365.3|385|12|RR|Rolls Royce|2|0|1|A
RR is keyed as category 235 so the outputed file will be:
ww-a10991t|rolls|5765|365.3|385|12|235|Rolls Royce|2|0|1|A
ww-a10991w|rolls|5763|365.3|385|12|235|Rolls Royce|2|0|1|A
ww-a10991b|rolls|5790|365.3|385|12|235|Rolls Royce|2|0|1|A
My problem is just that the size of the switching and checking seems
attrocious to do.
Thoughts, suggestions?
This is a flat file that I am then loading into MySQL and pulling the
data from it, and without this step of swapping category codes for a
category identification number gives me a HORRIBLE looking output as
well as a TON of errors.
TIA!
Robert
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]