Article 12310 of comp.lang.perl:
Path: feenix.metronet.com!news.ecn.bgu.edu!usenet.ins.cwru.edu!howland.reston.ans.net!cs.utexas.edu!uunet!meaddata!petew
From: petew@meaddata.com (Pete Williams)
Newsgroups: comp.lang.perl
Subject: ASCII<=>EBCDIC problem solved -- here's my solution!
Date: 5 Apr 1994 23:53:05 GMT
Organization: Mead Data Central, Dayton OH
Lines: 112
Message-ID: <2nstl1$brl@meaddata.meaddata.com>
NNTP-Posting-Host: fracture.meaddata.com

Hi Fellow Perl[er|ite|ette]s:

First of all, thanks to everyone who kindly responded to my
requests for help with ASCII/EBCDIC translations.  While I was
a bit surprised that there seemed to be no library modules to
do these conversions, I (with a little help from my friends)
now offer you just such a beast...

So much of our work revolves around IBM-style character conversions,
that I found it hard to live without this little item.  (I also hate
having to kick off "dd" as a subprocess!).

This is based on the ASCII<->EBCDIC/IBM tables from the GNU dd
source, so data that converts properly with "dd" should perform
similarly with this.  I've tested out the EBCDIC<->ASCII routine
quite a bit and it seems to work as advertised.  The ASCII<->IBM
stuff hasn't been tested at all (as I have no data to do so),
so CAVEAT WHOMEVER.

Please direct any complaints, bugs (and especially fixes!) to me
and I will handle reposting or whatever.

Enjoy, all you people living in the EBCDIC past (like me :-)


Pete

_/_/_/_/_/_/   _/_/_/_/_/_/_/_/_/_/_/_/     _/      "'Tis an ill wind that
   _/      _/ _/         _/    _/           _/       blows no minds"
  _/_/_/_/   _/_/_/     _/    _/_/_/_/_/_/_/_/_/   --Malaclypse the Younger
 _/         _/         _/    _/            _/
_/         _/_/_/_/   _/    _/_/_/_/     _/        == petew@meaddata.com ==


-------%x-------------------CUT-HERE-------------------%x-------


begin 750 ascebc.pl
M(R,C(R,C(R,C(R,C(R,C(R,C(R,C(R,C(R,C(R,C(R,C(R,C(R,C(R,C(R,C
M(R,C(R,C(R,C(R,C(R,C(R,C(R,C(R,C(R,C(R,C(PHC($%30T5"0RY03 HC
M"B,@57-A9V4Z"B,@("!R97%U:7)E("=A<V-E8F,N<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