You use 'inflate', whereas I believe the gzip man page mentions 'deflate' for the compression mode. Did I misunderstand? I suspect compress/deflate is analogous to making a balloon smaller by deflating it.

Assuming you want to send out content in gzip'ed form and the images are static, you may want to place them in a separate directory, serve them from a lightweight process (thttpd, nginx, or a lean apache) or behind a proxy server (squid, varnish, pound, whichever you prefer). Granted, that's a non-programming solution which may not fit your case.

For storing gzip'ed data, I suppose IO::Compress::Gzip would allow you to gzip() to store to a scalar reference.

Shamelessly stolen from the synopsis and altered off-the-cuff:

use IO::Compress::Gzip qw(gzip $GzipError); my $gzip_data; my $status = gzip $input => \$gzip_data [,OPTS] or die "gzip failed: $GzipError\n";

Would this be what you're looking for? I suppose it's not too difficult to send out $gzip_data to a HTTP client end of the Perl code. Or did I simply mistake what you're trying to do?


In reply to Re: Gzip inflate a variable by rkrieger
in thread Gzip inflate a variable by MonkDrew

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.