If your file is typical of the ones I work with, you're not going to do it with a simple one-liner. (Unless, of course, you don't mind long lines.)
The COMP-3 format is basically a packed BCD scheme with a trailing sign indicator. So each data byte will contain two digits (or a digit and the sign for the last byte) of your number. So if you take a number, say 54106 and you want to put it into a PIC 9(7) COMP-3 field, you:
(Converting that to code, adding error checking, etc., is left as an exercise for the reader.)
The main problem is that you need to pack in multiple COMP-3 fields, perhaps some floating point values (trickier to convert!) and perhaps some EBCDIC conversion as well. What fun!
I decode these sorts of files all the time. Tell me "I want your crappy C program to decode a mainframe file", and give me your EMail address, and I'll ship it to you. (I'm flying out of town and will be back Tuesday evening, so don't expect a reply before Wednesday morning.)
...roboticusIn reply to Re: ASCII text on UNIX (Sun/Solaris 10) to MVS packed decimal (comp-3) using perl pack inline command
by roboticus
in thread ASCII text on UNIX (Sun/Solaris 10) to MVS packed decimal (comp-3) using perl pack inline command
by jayw
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |