in reply to Re: Re: uuencoding to deal with line breaks
in thread uuencoding to deal with line breaks

Uuencoded output will always be larger than the input because what you're doing is mapping the 8-bit character set into a smaller one (6-bits?).

If you want to compress your data, use Compress:Zlib (or maybe some form of `gzip -cf`) and uuencode the compressed data like before.

If that's still too big for you (or if you like complications), you can save your data as

  $when|$to|$from|$subject|$body_length|$binary_compressed_body";

and use read or sysread to read $binary_compressed_body.

Come to think of it, if the formatting of the body is important to you, why not just save the number of lines in the body as the 5th data field rather than the body itself and have the exact body text follow it? So it would look like

$when|$to|$from|$subject|$lines_in_body
$body   # could be multi-lined
  • Comment on Re: Re: Re: uuencoding to deal with line breaks

Replies are listed 'Best First'.
Re: uuencoding to deal with line breaks
by epoptai (Curate) on Dec 19, 2000 at 04:51 UTC
    Thank you eg! Uuencoded zlib is the answer, it's about 85% smaller than plaintext.
    use Compress::Zlib; use HTML::Entities; sub zlibc{ # zlib compress $output = compress($input); $output = pack ("u", $output); $output = encode_entities($output)} sub zlibu{ # zlib uncompress $o = decode_entities($input); $o = unpack ("u", $o); $output = uncompress($o)}
    Update: suffered some downvotes because i didn't realize how badly color-coded perl would go over.

    That won't happen again =)