in reply to Re: Re: reversible pack()?
in thread reversible pack()?

gzip first then base64 encode. To decode undo in opposite order ie base64_decode then gunzip. Still a lot fatter than binary but a lot thinner than hex.

If you want to know something try Google. There are hundreds of websites dealing with compression. Try say 'tutorial data compression theory' and find sites like......why don't you have a look yourself.

It is trivial to test this. Just compress, encode a representative string, and check it for LENGTH. Repeat with another encoding. Compare to length of gzip string and you will see how much you are loosing.

use Compress::Zlib; use MIME::Base64; my $str = "Hello World! " x 3; my $gzip = Compress::Zlib::memGzip( $str ); my $hex = unpack 'H*', $gzip; my $base64 = encode_base64('Aladdin:open sesame'); my $str_len = length($str); my $gzip_len = length($gzip); my $hex_len = length($hex); my $base64_len = length($base64); # make binary printable ;-) $gzip = '#' x $gzip_len; printf "%3d: %s\n%3d: %s\n%3d: %s\n%3d: %s\n", $str_len, $str, $gzip_len, $gzip, $hex_len, $hex, $base64_len, $ba +se64; __DATA__ 39: Hello World! Hello World! Hello World! 36: #################################### 72: 1f8b0800000000000003f348cdc9c95708cf2fca495154f0c0c90100b9a8ae382 +7000000 29: QWxhZGRpbjpvcGVuIHNlc2FtZQ==

You will see the value of compression as you increaase the string length.

cheers

tachyon