parsing a variable length record from a mixed format file

C

chadmay

I have a flat file that had a mix of fixed length and variable length
records. I am parsing through each record and determining if each
field is accurate compared to the document. Dealing with the fixed
length records was easy, but I'm having difficulting with the variable
length records. Here is a snippet of my code and record 3
(ACCT_CLUS_NM) is a variable length record. Since the record in my
test file isn't 45 chars, my output file is incorrect. Since I know
that the largest that record 3 will be is 45 chars, how do I code for
it??

#!/usr/bin/perl

$loop=57;
$ifname=$ARGV[0];
$ofname=$ARGV[1];

if("${ifname}" eq "" | "${ofname}" eq "")
{
print "\nUsage: $0 input_file output_file\n";
exit;
}
if(!-f "$ifname" | !-r "$ifname")
{
print "$ifname doesn't exist or you do not have permission to read
it.\n";
exit 1;
}
if(-f "$ofname")
{
print "$ofname already exists.\n";
exit 1;
}

open(BATCHF, "$ifname") or die "Open failed: $!\n";
open(FBATCHF, ">> $ofname") or die "Open failed: $!\n";

while (<BATCHF>)
{
$RECIN=$_;
$fpos=0;
for ($cnt=1;$cnt<=$loop;$cnt++)
{
if($cnt==1){$reclength=4;$field="ACCOUNT_TYPE"};
if($cnt==2){$reclength=1;$field="TAB"};
if($cnt==3){$reclength=45;$field="ACCT_CLUS_NM"};
if($cnt==4){$reclength=1;$field="TAB"};
if($cnt==5){$reclength=9;$field="ACCT_NBR"};
if($cnt==6){$reclength=1;$field="TAB"};
if($cnt==7){$reclength=3;$field="CORP_ENT_CD"};
if($cnt==8){$reclength=1;$field="TAB"};
if($cnt==9){$reclength=9;$field="CUSTOMER_NO"};
if($cnt==10){$reclength=1;$field="TAB"};
if($cnt==11){$reclength=20;$field="D_BEN_AGMT_DESC"};
if($cnt==12){$reclength=1;$field="TAB"};
if($cnt==13){$reclength=10;$field="D_BEN_AGMT_EFF_DT"};
if($cnt==14){$reclength=1;$field="TAB"};
if($cnt==15){$reclength=8;$field="D_FUND_TYP_CD"};
if($cnt==16){$reclength=1;$field="TAB"};
if($cnt==17){$reclength=6;$field="D_PROD_TYP_CD"};
if($cnt==18){$reclength=1;$field="TAB"};
if($cnt==19){$reclength=8;$field="FOLDED_FUNDING_TYPE"};
if($cnt==20){$reclength=1;$field="TAB"};
if($cnt==21){$reclength=40;$field="GROUP_NAME"};
if($cnt==22){$reclength=1;$field="TAB"};
if($cnt==23){$reclength=9;$field="GROUP_NO"};
if($cnt==24){$reclength=1;$field="TAB"};
if($cnt==25){$reclength=2;$field="GRP_CAN_CD"};
if($cnt==26){$reclength=1;$field="TAB"};
if($cnt==27){$reclength=10;$field="GRP_CAN_DT"};
if($cnt==28){$reclength=1;$field="TAB"};
if($cnt==29){$reclength=10;$field="GS_ORIGL_EFF_DT"};
if($cnt==30){$reclength=1;$field="TAB"};
if($cnt==31){$reclength=20;$field="H_BEN_AGMT_DESC"};
if($cnt==32){$reclength=1;$field="TAB"};
if($cnt==33){$reclength=10;$field="H_BEN_AGMT_EFF_DT"};
if($cnt==34){$reclength=1;$field="TAB"};
if($cnt==35){$reclength=8;$field="H_FUND_TYP_CD"};
if($cnt==36){$reclength=1;$field="TAB"};
if($cnt==37){$reclength=6;$field="H_PROD_TYP_CD"};
if($cnt==38){$reclength=1;$field="TAB"};
if($cnt==39){$reclength=10;$field="LOAD_DT"};
if($cnt==40){$reclength=1;$field="TAB"};
if($cnt==41){$reclength=10;$field="LST_UPDT_DT"};
if($cnt==42){$reclength=1;$field="TAB"};
if($cnt==43){$reclength=4;$field="MKT_SEG_CD"};
if($cnt==44){$reclength=1;$field="TAB"};
if($cnt==45){$reclength=45;$field="NAME"};
if($cnt==46){$reclength=1;$field="TAB"};
if($cnt==47){$reclength=10;$field="ROW_EFFECTIVE_DT"};
if($cnt==48){$reclength=1;$field="TAB"};
if($cnt==49){$reclength=10;$field="ROW_END_DT"};
if($cnt==50){$reclength=1;$field="TAB"};
if($cnt==51){$reclength=5;$field="SECT_NBR"};
if($cnt==52){$reclength=1;$field="TAB"};
if($cnt==53){$reclength=40;$field="SECT_NM"};
if($cnt==54){$reclength=1;$field="TAB"};
if($cnt==55){$reclength=4;$field="SIC_CD"};
if($cnt==56){$reclength=1;$field="TAB"};
if($cnt==57){$reclength=10;$field="TIER_TYPE"};
chomp($RECIN);
$RECOUT=substr($RECIN,$fpos,$reclength);
$fpos=$reclength + $fpos;
print FBATCHF "$field $reclength |$RECOUT|\n";
}
print FBATCHF "------------------------------------------------\n";
}
close BATCHF;
close FBATCHF;
 
G

Greg Bacon

: I have a flat file that had a mix of fixed length and variable length
: records. I am parsing through each record and determining if each
: field is accurate compared to the document. Dealing with the fixed
: length records was easy, but I'm having difficulting with the variable
: length records. Here is a snippet of my code and record 3
: (ACCT_CLUS_NM) is a variable length record. Since the record in my
: test file isn't 45 chars, my output file is incorrect. Since I know
: that the largest that record 3 will be is 45 chars, how do I code for
: it??

Are the fields you tagged with "TAB" literal TAB characters? If so,
extracting the fields is easy:

@fields = split /\t/, $RECIN;

Hope this helps,
Greg
 
C

chadmay

: I have a flat file that had a mix of fixed length and variable length
: records. I am parsing through each record and determining if each
: field is accurate compared to the document. Dealing with the fixed
: length records was easy, but I'm having difficulting with the variable
: length records. Here is a snippet of my code and record 3
: (ACCT_CLUS_NM) is a variable length record. Since the record in my
: test file isn't 45 chars, my output file is incorrect. Since I know
: that the largest that record 3 will be is 45 chars, how do I code for
: it??

Are the fields you tagged with "TAB" literal TAB characters? If so,
extracting the fields is easy:

@fields = split /\t/, $RECIN;

Hope this helps,
Greg

You are correct, those are literal TABS that I've specificly listed in
the record layout. Since I'm somewhat of a PERL newbie, I want to make
sure I'm not missing anything. Where would I insert the line you
proposed and what other changes to my current code, do I need to make?

Thanks again,
Chad
 
T

tuser

I have a flat file that had a mix of fixed length and variable length
records. I am parsing through each record and determining if each
field is accurate compared to the document. Dealing with the fixed
length records was easy, but I'm having difficulting with the variable
length records. Here is a snippet of my code and record 3
(ACCT_CLUS_NM) is a variable length record. Since the record in my
test file isn't 45 chars, my output file is incorrect. Since I know
that the largest that record 3 will be is 45 chars, how do I code for
it??

I am not sure if I understand your question, but I suggest the
following changes to your program:
#!/usr/bin/perl

use strict;
use warnings;
$loop=57;
$ifname=$ARGV[0];
$ofname=$ARGV[1];

my $loop = 57;
my $ifname = $ARGV[0];
my $ofname = $ARGV[1];
if("${ifname}" eq "" | "${ofname}" eq "")
if ($ifname eq "" or $ofname eq "")

no need for curly braces here and no need to quote $ifname or $ofname,
see perlfaq4 (What's wrong with always quoting "$vars" ?).

use "or" instead of "|", see perldoc perlop ("Bitwise Or and Exclusive
Or" and "C-style Logical Or").
{
print "\nUsage: $0 input_file output_file\n";
exit;}

if(!-f "$ifname" | !-r "$ifname")

if (!-f $ifname or !-r "$ifname")

no curlies, that's good, but again, "or" instead of "|" and no need to
quote $ifname.
{
print "$ifname doesn't exist or you do not have permission to read
it.\n";
exit 1;}

if(-f "$ofname")

if (-f $ofname)
{
print "$ofname already exists.\n";
exit 1;

}

open(BATCHF, "$ifname") or die "Open failed: $!\n";
open(FBATCHF, ">> $ofname") or die "Open failed: $!\n";

open my $BATCHF, '<', $ifname or die "Open < $ifname failed: $!\n";
open my $FBATCHF, '>>', $ofname or die "Open >> $ofname failed: $!\n";
while (<BATCHF>)

while (<$BATCHF>)

[ ...snip... ]
for ($cnt=1;$cnt<=$loop;$cnt++)

for my $cnt (1..$loop)

[ ...snip... ]
print FBATCHF "$field $reclength |$RECOUT|\n";

print {$FBATCHF} "$field $reclength |$RECOUT|\n";
close BATCHF;
close FBATCHF;

close $BATCHF;
close $FBATCHF;
 
J

John W. Krahn

I have a flat file that had a mix of fixed length and variable length
records. I am parsing through each record and determining if each
field is accurate compared to the document. Dealing with the fixed
length records was easy, but I'm having difficulting with the variable
length records. Here is a snippet of my code and record 3
(ACCT_CLUS_NM) is a variable length record. Since the record in my
test file isn't 45 chars, my output file is incorrect. Since I know
that the largest that record 3 will be is 45 chars, how do I code for
it??

It looks like this may be close to what you want:

#!/usr/bin/perl
use warnings;
use strict;

@ARGV == 2 or die "\nUsage: $0 input_file output_file\n";

my ( $ifname, $ofname ) = @ARGV;

my @fields = qw(
ACCOUNT_TYPE
ACCT_CLUS_NM
ACCT_NBR
CORP_ENT_CD
CUSTOMER_NO
D_BEN_AGMT_DESC
D_BEN_AGMT_EFF_DT
D_FUND_TYP_CD
D_PROD_TYP_CD
FOLDED_FUNDING_TYPE
GROUP_NAME
GROUP_NO
GRP_CAN_CD
GRP_CAN_DT
GS_ORIGL_EFF_DT
H_BEN_AGMT_DESC
H_BEN_AGMT_EFF_DT
H_FUND_TYP_CD
H_PROD_TYP_CD
LOAD_DT
LST_UPDT_DT
MKT_SEG_CD
NAME
ROW_EFFECTIVE_DT
ROW_END_DT
SECT_NBR
SECT_NM
SIC_CD
TIER_TYPE
);

open BATCHF, '<', $ifname or die "Open '$ifname' failed: $!\n";
open FBATCHF, '>>', $ofname or die "Open '$ofname' failed: $!\n";

while ( my $RECIN = <BATCHF> ) {
chomp $RECIN;
@records = split /\t/, $RECIN, -1;
print FBATCHF map( "$fields[$_] " . length( $records[ $_ ] ) . "
|$records[$_]|\n", 0 .. $#fields ), '-' x 48, "\n";
}

close BATCHF;
close FBATCHF;








#!/usr/bin/perl

$loop=57;
$ifname=$ARGV[0];
$ofname=$ARGV[1];

if("${ifname}" eq "" | "${ofname}" eq "")
{
print "\nUsage: $0 input_file output_file\n";
exit;
}
if(!-f "$ifname" | !-r "$ifname")
{
print "$ifname doesn't exist or you do not have permission to read
it.\n";
exit 1;
}
if(-f "$ofname")
{
print "$ofname already exists.\n";
exit 1;
}

open(BATCHF, "$ifname") or die "Open failed: $!\n";
open(FBATCHF, ">> $ofname") or die "Open failed: $!\n";

while (<BATCHF>)
{
$RECIN=$_;
$fpos=0;
for ($cnt=1;$cnt<=$loop;$cnt++)
{
if($cnt==1){$reclength=4;$field="ACCOUNT_TYPE"};
if($cnt==2){$reclength=1;$field="TAB"};
if($cnt==3){$reclength=45;$field="ACCT_CLUS_NM"};
if($cnt==4){$reclength=1;$field="TAB"};
if($cnt==5){$reclength=9;$field="ACCT_NBR"};
if($cnt==6){$reclength=1;$field="TAB"};
if($cnt==7){$reclength=3;$field="CORP_ENT_CD"};
if($cnt==8){$reclength=1;$field="TAB"};
if($cnt==9){$reclength=9;$field="CUSTOMER_NO"};
if($cnt==10){$reclength=1;$field="TAB"};
if($cnt==11){$reclength=20;$field="D_BEN_AGMT_DESC"};
if($cnt==12){$reclength=1;$field="TAB"};
if($cnt==13){$reclength=10;$field="D_BEN_AGMT_EFF_DT"};
if($cnt==14){$reclength=1;$field="TAB"};
if($cnt==15){$reclength=8;$field="D_FUND_TYP_CD"};
if($cnt==16){$reclength=1;$field="TAB"};
if($cnt==17){$reclength=6;$field="D_PROD_TYP_CD"};
if($cnt==18){$reclength=1;$field="TAB"};
if($cnt==19){$reclength=8;$field="FOLDED_FUNDING_TYPE"};
if($cnt==20){$reclength=1;$field="TAB"};
if($cnt==21){$reclength=40;$field="GROUP_NAME"};
if($cnt==22){$reclength=1;$field="TAB"};
if($cnt==23){$reclength=9;$field="GROUP_NO"};
if($cnt==24){$reclength=1;$field="TAB"};
if($cnt==25){$reclength=2;$field="GRP_CAN_CD"};
if($cnt==26){$reclength=1;$field="TAB"};
if($cnt==27){$reclength=10;$field="GRP_CAN_DT"};
if($cnt==28){$reclength=1;$field="TAB"};
if($cnt==29){$reclength=10;$field="GS_ORIGL_EFF_DT"};
if($cnt==30){$reclength=1;$field="TAB"};
if($cnt==31){$reclength=20;$field="H_BEN_AGMT_DESC"};
if($cnt==32){$reclength=1;$field="TAB"};
if($cnt==33){$reclength=10;$field="H_BEN_AGMT_EFF_DT"};
if($cnt==34){$reclength=1;$field="TAB"};
if($cnt==35){$reclength=8;$field="H_FUND_TYP_CD"};
if($cnt==36){$reclength=1;$field="TAB"};
if($cnt==37){$reclength=6;$field="H_PROD_TYP_CD"};
if($cnt==38){$reclength=1;$field="TAB"};
if($cnt==39){$reclength=10;$field="LOAD_DT"};
if($cnt==40){$reclength=1;$field="TAB"};
if($cnt==41){$reclength=10;$field="LST_UPDT_DT"};
if($cnt==42){$reclength=1;$field="TAB"};
if($cnt==43){$reclength=4;$field="MKT_SEG_CD"};
if($cnt==44){$reclength=1;$field="TAB"};
if($cnt==45){$reclength=45;$field="NAME"};
if($cnt==46){$reclength=1;$field="TAB"};
if($cnt==47){$reclength=10;$field="ROW_EFFECTIVE_DT"};
if($cnt==48){$reclength=1;$field="TAB"};
if($cnt==49){$reclength=10;$field="ROW_END_DT"};
if($cnt==50){$reclength=1;$field="TAB"};
if($cnt==51){$reclength=5;$field="SECT_NBR"};
if($cnt==52){$reclength=1;$field="TAB"};
if($cnt==53){$reclength=40;$field="SECT_NM"};
if($cnt==54){$reclength=1;$field="TAB"};
if($cnt==55){$reclength=4;$field="SIC_CD"};
if($cnt==56){$reclength=1;$field="TAB"};
if($cnt==57){$reclength=10;$field="TIER_TYPE"};
chomp($RECIN);
$RECOUT=substr($RECIN,$fpos,$reclength);
$fpos=$reclength + $fpos;
print FBATCHF "$field $reclength |$RECOUT|\n";
}
print FBATCHF "------------------------------------------------\n";
}
close BATCHF;
close FBATCHF;







John
 
G

Greg Bacon

: You are correct, those are literal TABS that I've specificly listed in
: the record layout. Since I'm somewhat of a PERL newbie, I want to make
: sure I'm not missing anything. Where would I insert the line you
: proposed and what other changes to my current code, do I need to make?

John W. Krahn's followup seems to have a reasonable approach.
Has it made it to your news server? Does it help?

Greg
 
B

Brian McCauley

I have a flat file that had a mix of fixed length and variable length
records. I am parsing through each record and determining if each
field is accurate compared to the document. Dealing with the fixed
length records was easy, but I'm having difficulting with the variable
length records. Here is a snippet of my code and record 3
(ACCT_CLUS_NM) is a variable length record. Since the record in my
test file isn't 45 chars, my output file is incorrect. Since I know
that the largest that record 3 will be is 45 chars, how do I code for
it??

You cannot code for something you can't even describe. If you have a
record with a mix of fixed length and variable length fields you need
some property of the record that lets you determine how wide the
variable fields are. Since you've not described how you (a human)
could tell how long the ACCT_CLUS_NM field is in a given record
there's no way you can convert that lack of knowledge into working
code.

Sorry - I've just re-read this thread and realised this is a simple
tab delimited record, so you should simply split() it. (I was going to
tell you about unpack() and m//gc as approaches to mixed fixed/
variable with fields but neither of these are now relevant).
#!/usr/bin/perl

$loop=57;
$ifname=$ARGV[0];
$ofname=$ARGV[1];

if("${ifname}" eq "" | "${ofname}" eq "")
{
print "\nUsage: $0 input_file output_file\n";
exit;}

Please see other people's comments on cleaning up your Perl. In
particular decalre all variables as lexically scoped in the smallest
applicable scope unless there is a reason not to (this is not specific
to Perl). You can then tell perl to insist on explicit declaration. It
really will save you a lot of pain in future. When learning to climb
all those ropes do get in the way but after the first couple of slips
the effort pays off.
if(!-f "$ifname" | !-r "$ifname")
{
print "$ifname doesn't exist or you do not have permission to read
it.\n";
exit 1;}

Remove that block of code - the error handling on open() already does
a better job of telling the user what's actually wrong.
if(-f "$ofname")
{
print "$ofname already exists.\n";
exit 1;

}
open(FBATCHF, ">> $ofname") or die "Open failed: $!\n";

Why are you trying to append to a file that you've just checked does
not already exist? This won't confuse the computer but it sure does
confuse any human who looks at your code.
if($cnt==1){$reclength=4;$field="ACCOUNT_TYPE"};
if($cnt==2){$reclength=1;$field="TAB"};
if($cnt==56){$reclength=1;$field="TAB"};
if($cnt==57){$reclength=10;$field="TIER_TYPE"};

If you are doing the same thing 3 times you are probably doing it
wrong. You are doing the same thing 57 times. The word "array" should
be burning so brightly in your mind's eye that smoke should be issuing
from your ears.
 
C

chadmay

I have a flat file that had a mix of fixed length and variable length
records. I am parsing through each record and determining if each
field is accurate compared to the document. Dealing with the fixed
length records was easy, but I'm having difficulting with the variable
length records. Here is a snippet of my code and record 3
(ACCT_CLUS_NM) is a variable length record. Since the record in my
test file isn't 45 chars, my output file is incorrect. Since I know
that the largest that record 3 will be is 45 chars, how do I code for
it??

You cannot code for something you can't even describe. If you have a
record with a mix of fixed length and variable length fields you need
some property of the record that lets you determine how wide the
variable fields are. Since you've not described how you (a human)
could tell how long the ACCT_CLUS_NM field is in a given record
there's no way you can convert that lack of knowledge into working
code.

Sorry - I've just re-read this thread and realised this is a simple
tab delimited record, so you should simply split() it. (I was going to
tell you about unpack() and m//gc as approaches to mixed fixed/
variable with fields but neither of these are now relevant).


#!/usr/bin/perl
$loop=57;
$ifname=$ARGV[0];
$ofname=$ARGV[1];

if("${ifname}" eq "" | "${ofname}" eq "")
{
print "\nUsage: $0 input_file output_file\n";
exit;}

Please see other people's comments on cleaning up your Perl. In
particular decalre all variables as lexically scoped in the smallest
applicable scope unless there is a reason not to (this is not specific
to Perl). You can then tell perl to insist on explicit declaration. It
really will save you a lot of pain in future. When learning to climb
all those ropes do get in the way but after the first couple of slips
the effort pays off.
if(!-f "$ifname" | !-r "$ifname")
{
print "$ifname doesn't exist or you do not have permission to read
it.\n";
exit 1;}

Remove that block of code - the error handling on open() already does
a better job of telling the user what's actually wrong.
if(-f "$ofname")
{
print "$ofname already exists.\n";
exit 1;
}
open(FBATCHF, ">> $ofname") or die "Open failed: $!\n";

Why are you trying to append to a file that you've just checked does
not already exist? This won't confuse the computer but it sure does
confuse any human who looks at your code.
if($cnt==1){$reclength=4;$field="ACCOUNT_TYPE"};
if($cnt==2){$reclength=1;$field="TAB"};
if($cnt==56){$reclength=1;$field="TAB"};
if($cnt==57){$reclength=10;$field="TIER_TYPE"};

If you are doing the same thing 3 times you are probably doing it
wrong. You are doing the same thing 57 times. The word "array" should
be burning so brightly in your mind's eye that smoke should be issuing
from your ears.
 
C

chadmay

I have a flat file that had a mix of fixed length and variable length
records. I am parsing through each record and determining if each
field is accurate compared to the document. Dealing with the fixed
length records was easy, but I'm having difficulting with the variable
length records. Here is a snippet of my code and record 3
(ACCT_CLUS_NM) is a variable length record. Since the record in my
test file isn't 45 chars, my output file is incorrect. Since I know
that the largest that record 3 will be is 45 chars, how do I code for
it??

It looks like this may be close to what you want:

#!/usr/bin/perl
use warnings;
use strict;

@ARGV == 2 or die "\nUsage: $0 input_file output_file\n";

my ( $ifname, $ofname ) = @ARGV;

my @fields = qw(
ACCOUNT_TYPE
ACCT_CLUS_NM
ACCT_NBR
CORP_ENT_CD
CUSTOMER_NO
D_BEN_AGMT_DESC
D_BEN_AGMT_EFF_DT
D_FUND_TYP_CD
D_PROD_TYP_CD
FOLDED_FUNDING_TYPE
GROUP_NAME
GROUP_NO
GRP_CAN_CD
GRP_CAN_DT
GS_ORIGL_EFF_DT
H_BEN_AGMT_DESC
H_BEN_AGMT_EFF_DT
H_FUND_TYP_CD
H_PROD_TYP_CD
LOAD_DT
LST_UPDT_DT
MKT_SEG_CD
NAME
ROW_EFFECTIVE_DT
ROW_END_DT
SECT_NBR
SECT_NM
SIC_CD
TIER_TYPE
);

open BATCHF, '<', $ifname or die "Open '$ifname' failed: $!\n";
open FBATCHF, '>>', $ofname or die "Open '$ofname' failed: $!\n";

while ( my $RECIN = <BATCHF> ) {
chomp $RECIN;
@records = split /\t/, $RECIN, -1;
print FBATCHF map( "$fields[$_] " . length( $records[ $_ ] ) . "
|$records[$_]|\n", 0 .. $#fields ), '-' x 48, "\n";
}

close BATCHF;
close FBATCHF;






#!/usr/bin/perl
$loop=57;
$ifname=$ARGV[0];
$ofname=$ARGV[1];

if("${ifname}" eq "" | "${ofname}" eq "")
{
print "\nUsage: $0 input_file output_file\n";
exit;
}
if(!-f "$ifname" | !-r "$ifname")
{
print "$ifname doesn't exist or you do not have permission to read
it.\n";
exit 1;
}
if(-f "$ofname")
{
print "$ofname already exists.\n";
exit 1;
}
open(BATCHF, "$ifname") or die "Open failed: $!\n";
open(FBATCHF, ">> $ofname") or die "Open failed: $!\n";
while (<BATCHF>)
{
$RECIN=$_;
$fpos=0;
for ($cnt=1;$cnt<=$loop;$cnt++)
{
if($cnt==1){$reclength=4;$field="ACCOUNT_TYPE"};
if($cnt==2){$reclength=1;$field="TAB"};
if($cnt==3){$reclength=45;$field="ACCT_CLUS_NM"};
if($cnt==4){$reclength=1;$field="TAB"};
if($cnt==5){$reclength=9;$field="ACCT_NBR"};
if($cnt==6){$reclength=1;$field="TAB"};
if($cnt==7){$reclength=3;$field="CORP_ENT_CD"};
if($cnt==8){$reclength=1;$field="TAB"};
if($cnt==9){$reclength=9;$field="CUSTOMER_NO"};
if($cnt==10){$reclength=1;$field="TAB"};
if($cnt==11){$reclength=20;$field="D_BEN_AGMT_DESC"};
if($cnt==12){$reclength=1;$field="TAB"};
if($cnt==13){$reclength=10;$field="D_BEN_AGMT_EFF_DT"};
if($cnt==14){$reclength=1;$field="TAB"};
if($cnt==15){$reclength=8;$field="D_FUND_TYP_CD"};
if($cnt==16){$reclength=1;$field="TAB"};
if($cnt==17){$reclength=6;$field="D_PROD_TYP_CD"};
if($cnt==18){$reclength=1;$field="TAB"};
if($cnt==19){$reclength=8;$field="FOLDED_FUNDING_TYPE"};
if($cnt==20){$reclength=1;$field="TAB"};
if($cnt==21){$reclength=40;$field="GROUP_NAME"};
if($cnt==22){$reclength=1;$field="TAB"};
if($cnt==23){$reclength=9;$field="GROUP_NO"};
if($cnt==24){$reclength=1;$field="TAB"};
if($cnt==25){$reclength=2;$field="GRP_CAN_CD"};
if($cnt==26){$reclength=1;$field="TAB"};
if($cnt==27){$reclength=10;$field="GRP_CAN_DT"};
if($cnt==28){$reclength=1;$field="TAB"};
if($cnt==29){$reclength=10;$field="GS_ORIGL_EFF_DT"};
if($cnt==30){$reclength=1;$field="TAB"};
if($cnt==31){$reclength=20;$field="H_BEN_AGMT_DESC"};
if($cnt==32){$reclength=1;$field="TAB"};
if($cnt==33){$reclength=10;$field="H_BEN_AGMT_EFF_DT"};
if($cnt==34){$reclength=1;$field="TAB"};
if($cnt==35){$reclength=8;$field="H_FUND_TYP_CD"};
if($cnt==36){$reclength=1;$field="TAB"};
if($cnt==37){$reclength=6;$field="H_PROD_TYP_CD"};
if($cnt==38){$reclength=1;$field="TAB"};
if($cnt==39){$reclength=10;$field="LOAD_DT"};
if($cnt==40){$reclength=1;$field="TAB"};
if($cnt==41){$reclength=10;$field="LST_UPDT_DT"};
if($cnt==42){$reclength=1;$field="TAB"};
if($cnt==43){$reclength=4;$field="MKT_SEG_CD"};
if($cnt==44){$reclength=1;$field="TAB"};
if($cnt==45){$reclength=45;$field="NAME"};
if($cnt==46){$reclength=1;$field="TAB"};
if($cnt==47){$reclength=10;$field="ROW_EFFECTIVE_DT"};
if($cnt==48){$reclength=1;$field="TAB"};
if($cnt==49){$reclength=10;$field="ROW_END_DT"};
if($cnt==50){$reclength=1;$field="TAB"};
if($cnt==51){$reclength=5;$field="SECT_NBR"};
if($cnt==52){$reclength=1;$field="TAB"};
if($cnt==53){$reclength=40;$field="SECT_NM"};
if($cnt==54){$reclength=1;$field="TAB"};
if($cnt==55){$reclength=4;$field="SIC_CD"};
if($cnt==56){$reclength=1;$field="TAB"};
if($cnt==57){$reclength=10;$field="TIER_TYPE"};
chomp($RECIN);
$RECOUT=substr($RECIN,$fpos,$reclength);
$fpos=$reclength + $fpos;
print FBATCHF "$field $reclength |$RECOUT|\n";
}
print FBATCHF "------------------------------------------------\n";
}
close BATCHF;
close FBATCHF;

John
--
Perl isn't a toolbox, but a small machine shop where you can special-order
certain sorts of tools at low cost and in short order. -- Larry Wall- Hide quoted text -

- Show quoted text -

Problem is solved now, Thanks John!
 
T

Tad McClellan

Josef Moellers said:
What was the reason to quote the entire thread just to add a single line?


To cut down on the number of articles that I need to read.

:-(
 
T

Tad McClellan

Dave Weaver said:
In a bid for even more readability, I'd write the above as

if ( not -f $ifname or not -r $ifname ) {


In a bid for faster execution, I'd write the above as

if ( not -f $ifname or not -r _ ) {
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,733
Messages
2,569,440
Members
44,832
Latest member
GlennSmall

Latest Threads

Top