[LA.pm] calling gzip from within perl

David Heayn david at cloudgraphics.com
Tue Jun 28 22:21:30 PDT 2005


At 12:36 PM +0800 6/29/05, Benjamin J. Tilly  wrote:
>Why do you need to decompress them beforehand?
>
>   open(LOG, "gunzip $file |") or die "Cannot gunzip '$file': $!";
>
>Or you can avoid the implicit system command by using
>Compress::Zlib.

I tried the code above. It decompressed the files (and erased the 
original) but perl didn't properly display them. In fact, it 
displayed nothing but the html title and header.

The changed code is below.

if (param('action'))
	{
	print header;
	my $year = param('year');
	my $month = param('mo');
	my $day = param('day');
	my $seekLog = "access_log-$month.$day.$year";
	my $fileLoc = "$logDir$seekLog.gz";
	open(FILE, "gunzip $fileLoc |") or die "Cannot gunzip '$fileLoc': $!";
	my @stuff = <FILE>;
	close(FILE);


Do i need to install compress:zlib to get this to work correctly?



thanks!

(oh, and I love this list)

David Heayn * http://www.cloudgraphics.com * 213/925.3283


More information about the Losangeles-pm mailing list