I really appreciate this guys.  Thanks!

Sean

-----Original Message-----
From: Steve Grazzini [mailto:[EMAIL PROTECTED]]On Behalf Of Steve
Grazzini
Sent: Friday, August 23, 2002 6:55 PM
To: [EMAIL PROTECTED]
Subject: Re: can't find eof on ebcdic file


John W. Krahn <[EMAIL PROTECTED]> wrote:
> Sean Rowe wrote:
>> Is there a way to convert, say a 10 meg file, from EBCDIC to 
>> ASCII quickly?
> 
> This should be pretty fast.
> 
> # table borrowed from snippets file a2e.c
> my %e2a = do { my $i; map { chr, chr( $i++ ) } 
> (         0 .. 3, 156, 9, 134, 127, 151, 141, 142,
>          11 .. 19, 157, 133, 8, 135, 24, 25, 146,
>         143, 28 .. 31, 128 .. 132, 10, 23, 27,
>         136 .. 140, 5 .. 7, 144, 145, 22, 147 .. 150,
>           4, 152 .. 155, 20, 21, 158, 26, 32,
>         160 .. 168, 91, 46, 60, 40, 43, 33, 38,
>         169 .. 177, 93, 36, 42, 41, 59, 94, 45, 47,
>         178 .. 185, 124, 44, 37, 95, 62, 63,
>         186 .. 194, 96, 58, 35, 64, 39, 61, 34, 195,
>          97 .. 99, 100 .. 105, 196 .. 202, 106 .. 114,
>         203 .. 209, 126, 115 .. 122, 210 .. 231, 123,
>          65 .. 73, 232 .. 237, 125, 74 .. 82, 238 .. 243,
>          92, 159, 83 .. 90, 244 .. 249, 48 .. 57, 250 .. 255,
> ) };
> 
> 
> open INFILE, $EbcdicFile or die "Could not open $EbcdicFile: $!";
> binmode INFILE;
> 
> $/ = \16384;  # Input buffer size
>               # adjust to taste
> 
> while ( <INFILE> ) {
>     s/(.)/$e2a{$1}/sg;
>     print OUTFILE;
>     }

This should be a bit faster... :)

  %e2a = do { my $i; map { $_, $i++ }

    ... same table ...

  };
 
  $e = sprintf '\%o'x256, keys %e2a;
  $a = sprintf '\%o'x256, values %e2a;

  eval "tr/$e/$a/, print while <INFILE>";

-- 
Steve

perldoc -qa.j | perl -lpe '($_)=m("(.*)")'

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to