I am having an issue with one of the output fields occasionally being written at 46 bytes instead of the stated 45 bytes when using the printf function.
I am hoping that another set of eyes can identify what I have been missing. I have read through the perldoc -f sprintf to verify my parameters (doesn't mean I can't miss something) and it "appears" that the format is correct.
Here are a couple of actual input records:
1.111.25.6 BR# 6 L25 INTEREST ON PARTIAL COLLATTERAL LOAN C 0 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00
1.111.25.74 BR# 74 L25 INTEREST ON PARTIAL COLLATTERAL C 0 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00
LOAN
Notice on the 2nd record that the word "LOAN" is on a line by itself. It appears that this may be a word wrap from the program that created this source file (outside source). My code is attempting to skip/bypass these lines by checking for short lines (there is a \r\n immediately following the word LOAN in the 3rd record.
Here is a snippet of my code for viewing:
@GLC is a 4 element array
@GLA is a 12 element array
# Output Fixed Format GL Account Record
printf OFH
("%03d%03d%03d%03d%s%15s%-45s%-s%13d%13d%13d%13d%13d%13d%13d%13d%13d%13d%13d%13d%13d\n",@GLC,$GFT,$GLN,$GLD,$GLT,$GLO,@GLA);
Here is the output of a few records:
0011110250061 1.111.25.6BR# 6 L25 INTEREST ON PARTIAL COLLATTERAL LOAC 0 0 0 0 0 0 0 0 0 0 0 0 0
0011110250061 1.111.25.6BR# 6 L25 INTEREST ON PARTIAL COLLATTERAL LOANC 0 0 0 0 0 0 0 0 0 0 0 0 0
Notice that on the 1st recod the description is truncated to LOA as expected. However, on the 2nd record, the description is NOT truncated resulting in all characters to its right to be offset by 1 byte.
Please don't make fun of my rather short fieldnames s they are compliant with the client's data dictionary.
Any ideas GREATLY appreciated. I am sure that I am missing something here.
Thanks
I am hoping that another set of eyes can identify what I have been missing. I have read through the perldoc -f sprintf to verify my parameters (doesn't mean I can't miss something) and it "appears" that the format is correct.
Here are a couple of actual input records:
1.111.25.6 BR# 6 L25 INTEREST ON PARTIAL COLLATTERAL LOAN C 0 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00
1.111.25.74 BR# 74 L25 INTEREST ON PARTIAL COLLATTERAL C 0 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00
LOAN
Notice on the 2nd record that the word "LOAN" is on a line by itself. It appears that this may be a word wrap from the program that created this source file (outside source). My code is attempting to skip/bypass these lines by checking for short lines (there is a \r\n immediately following the word LOAN in the 3rd record.
Here is a snippet of my code for viewing:
@GLC is a 4 element array
@GLA is a 12 element array
# Output Fixed Format GL Account Record
printf OFH
("%03d%03d%03d%03d%s%15s%-45s%-s%13d%13d%13d%13d%13d%13d%13d%13d%13d%13d%13d%13d%13d\n",@GLC,$GFT,$GLN,$GLD,$GLT,$GLO,@GLA);
Here is the output of a few records:
0011110250061 1.111.25.6BR# 6 L25 INTEREST ON PARTIAL COLLATTERAL LOAC 0 0 0 0 0 0 0 0 0 0 0 0 0
0011110250061 1.111.25.6BR# 6 L25 INTEREST ON PARTIAL COLLATTERAL LOANC 0 0 0 0 0 0 0 0 0 0 0 0 0
Notice that on the 1st recod the description is truncated to LOA as expected. However, on the 2nd record, the description is NOT truncated resulting in all characters to its right to be offset by 1 byte.
Please don't make fun of my rather short fieldnames s they are compliant with the client's data dictionary.
Any ideas GREATLY appreciated. I am sure that I am missing something here.
Thanks