You could do something like this (including the comma delimeter)...

# a sample record
my $record = "blah1\tblah2\tblah3";

# 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,2];

# print the comma delimeted fields
print join(',', @fields);


Rob

-----Original Message-----
From: Scott [mailto:[EMAIL PROTECTED]]
Sent: Wednesday, January 02, 2002 11:22 AM
To: [EMAIL PROTECTED]
Subject: Parsing large text files


Hi:

I am developing a input routine in perl that will take a SQL exported file 
in tab delimited format and convert it to something that our mainframe can 
process.  The file will ultimately have 255 characters for each field.  

I have been successful in replacing the tabs with comma's, but now need 
to make sure there are 255 characters per field.  I also need to filter 
data out of the exported file that will be dropped before it gets to the 
mainframe (unused fields).

My question is, would it be wise to pull the field into a database and 
then do an export on just the fields I need or something else??

tia,

-Scott


-- 
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]

Reply via email to