"Should I put a while in front of the line processing?"

Yup.

while ( my $record = <QUOTEP> ) {
  ...
}
close (NEWQUOTES);
close (QUOTEP);

Rob


-----Original Message-----
From: Scott [mailto:[EMAIL PROTECTED]]
Sent: Wednesday, January 02, 2002 2:50 PM
To: Hanson, Robert
Cc: [EMAIL PROTECTED]
Subject: RE: Parsing large text files


Ok, I think I have it opening the file correctly, now I want to create a 
loop to process every record in the file.  With the code below it does one 
line and stops.  Should I put a while in front of the line processing?

Thanks,




open(QUOTEP,"$qivQuoteFile");
open(NEWQUOTES, ">newtest5.txt");
my $record = <QUOTEP>;
# split by tabs
my @fields = split( /\t/, $record );
for (my $i = 0; $i < @fields; $i++ ) {
        # add 255 spaces to the field
        $fields[$i] .= " " x 255;
        # removes from 255th char forward
        $fields[$i] = substr($fields[$i],0,255);
}
# only include fields #0 and #2 (change to your needs)
#@fields = @fields[0,1,2,3,4,5,6,7,8,9,10];
print NEWQUOTES "00";
print NEWQUOTES "IN201";
printf NEWQUOTES ("%04d%02d%02d", $year+1900, $month+1, $day);
printf NEWQUOTES ("%02d%02d%02d", $hour,$minutes,$seconds);
print NEWQUOTES "@fields[01]\n";

print NEWQUOTES "01";
print NEWQUOTES "QTE";

#print NEWQUOTES join(',', @fields);
close (NEWQUOTES);
close (QUOTEP);




















On Wed, 2 Jan 2002, Hanson, Robert wrote:
> Do you mean do I recommend slurping the entire file into an array, and
then
> process each array element (ie. line)?  If the file is large (1Meg+) you
> probably don't want to do that.

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to