I'm using Convert::IBM390
to convert EBCDIC files to ASCII files.
#!/usr/bin/perl -w
use warnings;
use Convert::IBM390 qw(:all);
open EBCDIC, "<D:/EBCDIC.txt" or die "error -> opening $!";
open ASCII, ">D:/ASCII.txt" or die "error -> opening $!";
my $text;
my $template = 'e15.0 e15 z4 I2 I2 i2 N16.0 p11.0';
binmode EBCDIC;
while (read (EBCDIC, $buffer, 67))
{
@fields = unpackeb($template, $buffer);
$text= join(",",@fields);
print ASCII $text."\n";
}
close EBCDIC;
close ASCII;
I got this script in this link
I have problems when the EBCDIC data contain Little or Big Endian integers.
I had searched for unpacking those character and used N/n V/v but those things are not accepted in this module. got error as
Invalid type in unpackeb: 'N'
The EBCDIC FILE from the mainframe consists of following columns:
EBCDIC Decimal(15,0)
EBCDIC String(15)
Zoned Decimal(4)
unsigned little endian integer(2)
unsigned big endian integer(2)
signed big endian integer(2)
big endian decimal(16,0)
packed decimal(11,0)
Any suggestions ?