Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Compression Compress::Zlib

Status
Not open for further replies.

shezam

Programmer
Jan 30, 2009
11
IE
Perl dummy here. I need to use Compress::Zlib > DEFLATE to write the contents of an array i.e "@data" to a .gz file. Been reading the syntax but I'm little lost. Can the $output be a .gz file. Anyone with any suggestions greatly appreciated.
 
From the perldoc
Code:
This script, gzstream, does the opposite of the gzcat script above. It reads from standard input and writes a gzip file to standard output.

    use Compress::Zlib ;
    binmode STDOUT; # gzopen only sets it on the fd
    my $gz = gzopen(\*STDOUT, "wb")
          or die "Cannot open stdout: $gzerrno\n" ;
    while (<>) {
        $gz->gzwrite($_) 
            or die "error writing: $gzerrno\n" ;
    }
    $gz->gzclose ;

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
[noevil]
Travis - Those who say it cannot be done are usually interrupted by someone else doing it; Give the wrong symptoms, get the wrong solutions;
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top