PugSA has asked for the wisdom of the Perl Monks concerning the following question:

Hi
I was recently asked to convert Ascii to ebcdic packed for a os390 mainframe, I'm using the packeb function but the client says it is not the desired output. I'm a bit clueless of the mainframe enviroment, if there is someone that can advise.
I wrote a small script just to test the output here goes:...

Difinition & Layout
These are 6 fields of a 97 field layout
--------------------------------------------------------
FLD W 80 A
FLD-1 FLD 2 P VALUE 001 Pic s9(3) Comp-3
FLD-2 FLD +02 2 P VALUE 001 Pic s9(3) Comp-3
FLD-3 FLD +04 3 P VALUE 00000 Pic s9(5) Comp-3
FLD-4 FLD +07 2 P VALUE 000 Pic s9(3) Comp-3
FLD-5 FLD +09 3 P VALUE 00000 Pic s9(5) Comp-3
FLD-6 FLD +11 5 A VALUE 'FNUT ' Pic x(5)
---------------------------------------------------------

Code
Here is the code I tried. I don't know how to test the output I currently send it to the client,to test it on the mainframe, but if you know of a win32 viewer that I can use to test the output for OS390, will be awsome.
-----------------------------------------------------------
#!c:\perl\bin\perl -w use Convert::IBM390 qw(:all); unless (open(OUTPUT, ">a2e.txt")) { die ("cannot open configuration file \n"); } @var=("001","001","00000","000","00000","FNUT"); foreach(@var) { print $_; } #$template='p1.0 p1.0 p3.0 p1.0 p3.0 E5'; $template='p3 p3 p5 p3 p5 E5'; $ebout = packeb($template, @var); print OUTPUT ($ebout);
-----------------------------------------------------------

Thank You

Replies are listed 'Best First'.
Re: Ascii to ebcdic packed for os390
by Anonymous Monk on Apr 26, 2005 at 07:35 UTC
    perldoc -f binmode
      I've been wandering through the monastery, and found discussions on ascii to ebcdic conversions.Someone refered to dd please what is it.
        I'm unfortunately still on windows thats why I didn't know
      As warned by an anonymous monk the IBM390 module removes leading zeros when converting it to ebcdic packed. Does anyone have a sollution for this I've been stuck for over a week now and I'm not to sure how the binmode will help me (still need allot to learn) Thank You