in reply to File Compression???

I'm not sure of the wisdom of doing this, but, just for laffs... Two files letssee.pl and Mongo.pm:


### letssee.pl use strict; use warnings; use Mongo; my $buffer = Mongo::payload(); print $buffer; __END__

### Mongo.pm use strict; use warnings; package Mongo; use PerlIO::gzip; 1; # appease require sub payload { binmode( DATA, ':gzip' ); local $/ = \4096; my $ret; $ret .= $_ while <DATA>; return $ret; } __DATA__

Now, append compressed data to Mongo.pm, so that it can be accessed through its DATA handle.

% echo 'hello world'| gzip -c - >> Mongo.pm
Lastly, run letssee.pl:
% perl letssee.pl hello world
The Mongo::payload method reads the compressed payload from the DATA handle, uncompressing it on the fly. See PerlIO and PerlIO::gzip for more details on PerlIO layers.

Replies are listed 'Best First'.
Re^2: File Compression???
by Anonymous Monk on Jun 28, 2005 at 17:15 UTC
    That works great!...I ended up using Tie::gzip instead on Windows.
    Thanks Again!