in reply to Re: Gzip inflate a variable
in thread Gzip inflate a variable

Yeah, you are right... sorry. Your analogy makes sense now. Basically my perl script is the entire HTTP server, so it handles accessing the filesystem and caching. So I guess using your example I can have the contents of the image in variable $foo. Then do:
use IO::Compress::Gzip qw(gzip $GzipError); my $compressed; if(gzip $foo => \$compressed [,OPTS]){ # Compressed version of $foo stored in $compressed }

Replies are listed 'Best First'.
Re^3: Gzip inflate a variable
by pmqs (Friar) on Jan 22, 2010 at 14:21 UTC
    That's not quite correct. To read from a variable and write to a variable you need to add a backslash to both the input & output variables
    use IO::Compress::Gzip qw(gzip $GzipError); my $compressed; if(gzip \$foo => \$compressed [,OPTS]){ # Compressed version of $foo stored in $compressed }
    If you want the output to go to a filehandle
    # assume $fh is a filehandle ... gzip \$foo => $fh
    If you want to send the output to standard output, use "-"
    gzip \$foo => "-"
    Paul