Hello everyone, I am trying to convert my file into a comma delimited file but I am having trouble with the unpack and print. I have set my fields and set my unpack field characters, but when I run the process I get no results. Any help would be great.
use strict; use warnings; open (NEW, ">", "WK_OUTPUT_TEST.txt" ) or die "could not open:$!"; open (FILE, "<", "WK_OUTPUT.txt") or die "could not open:$!"; while (<FILE>) { $line = $_; $line .= ‘ ‘ x (280 – length($line)); #single space between th +e ‘ ‘ ($acct, $name, $ddte, $amt1, $amt2, #amt3, $can, $note, $ndte, + $bar, $ins) = unpack(‘A10A50A8A10A10A10A8A30A8A8A8’, $line); Print NEW “\"$acct\",”; Print NEW “\”$name\”,”; Print NEW “$ddte,”; Print NEW “$amt1,”; Print NEW “$amt2,”; Print NEW “$amt3,”; Print NEW “\"$can\”,”; Print NEW “\"$note\”,”; Print NEW “$ndte,”; Print NEW “\"$bar\”,”; Print NEW “\"$ins\”,”; Print NEW "\n"; } close (FILE); close (NEW)
INPUT FILE:
A123456789 DOE, JANE + 08/10/16 319.25 23.00 54.27 + CLMPD Claim paid correctly +per 08/15/17 BAR.ID HMO + A123456789 DOE, JANE + 08/10/16 23.00 54.27 + CLMPD + 08/15/17 + BAR.ID HMO A123456789 DOE, JANE + 08/10/16 319.25 54.27 + CLMPD Contract Calculation- + 08/15/17 BAR.ID
EXPECTED OUTPUT:
A123456785 “,” DOE, JANE “,” 08/10/16 ”,” 319.25 ”,” 23.00 "," 54.27 ” +,” CLMPD ”,” Claim paid correctly per ”,” 08/15/17 ”,” BAR.ID ”, +” HMO A123456786 “,” DOE, JANE “,” 08/10/16 ”,” ”,” 23.00 "," 54.27 ” +,” CLMPD ”,” ”,” 08 +/15/17 ”,” BAR.ID ”,” HMO A123456787 “,” DOE, JANE “,”08/10/16 ”,” 319.25 ”,” "," 54.27 ” +,” CLMPD ”,” Contract Calculation- ”,” 08/15/17 ”,” BAR.ID +”,” PPO
In reply to Unpack and Print NEW by jlope043
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |