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 dencom on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Compress::Zlib Troubles 1

Status
Not open for further replies.

gshirey

Programmer
Apr 11, 2001
12
US
I am trying to write a script that creates a tar file (using Archive::tar) and then compress that file using the gzip tools found within zlib.pm.

I have no trouble writing the tar file, nor creating a gzip file, however, I cannot figure out how to write anything to the .gz file.

If anyone has any good examples, or has developed a script along these lines, I would be most appreciative if I could look it over.

Thanks
 
Hey gshirey,
Fancy meeting you here.

I got this to work. Maybe it is close to what you are trying to do.

Code:
#!perl
use Compress::Zlib;

# put what ever you want in $buffer
$buffer = 'some text to write to the file.';

# you might want to use a different file name, other than 'junk.gz'
$gz = gzopen("junk.gz","wb") or die "Cannot open junk.gz: $gzerrno\n" ; 

# write $buffer content into gzip file.
$gz->gzwrite($buffer);

# close gzip file
$gz->gzclose;


HTH






keep the rudder amid ship and beware the odd typo
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top