Convert-BinHex
view release on metacpan or search on metacpan
lib/Convert/BinHex.pm view on Meta::CPAN
=item BinHex needs a stateful parser
Unlike its cousins I<base64> and I<uuencode>, BinHex format is not
amenable to being parsed line-by-line. There appears to be no
guarantee that lines contain 4n encoded characters... and even if there
is one, the BinHex compression algorithm interferes: even when you
can I<decode> one line at a time, you can't necessarily
I<decompress> a line at a time.
For example: a decoded line ending with the byte C<\x90> (the escape
or "mark" character) is ambiguous: depending on the next decoded byte,
it could mean a literal C<\x90> (if the next byte is a C<\x00>), or
it could mean n-1 more repetitions of the previous character (if
the next byte is some nonzero C<n>).
For this reason, a BinHex parser has to be somewhat stateful: you
cannot have code like this:
#### NO! #### NO! #### NO! #### NO! #### NO! ####
while (<STDIN>) { # read HEX
print hexbin($_); # convert and write BIN
( run in 0.765 second using v1.01-cache-2.11-cpan-26ccb49234f )