Michael Alipio wrote:
From: Rob Dixon <[EMAIL PROTECTED]>
Michael Alipio wrote:
After parsing a log and writing it into a file, I now, have to compress
it into tar.gz. Right now, I'm doing a search at CPAN and there where too
many modules out there with "compress" or "archive" search keyword.
What do you suggest?
Archive::Tar
Right now, I'm playing with Compress::Zlib.
[snip]
sub extractlog {
my $clientname=shift;
my $log=shift;
my $year=shift;
my $date=shift;
## create the necessary path in "/client_name/year" notation
mkpath ($clientname.'/'.$year,1);
my $datedlog = $clientname.'/'.$year.'/'.$date.'.log'.'.gz';
## the actual log file destination (e.g; client1/2007/2007-01-12.log.gz)
my $gzlogfile = gzopen($datedlog, "ab9");
my $path = "$clientname/$year";
my $file = "$date.log.gz";
## create the necessary path in "/client_name/year" notation
mkpath ($path, 1);
my $gzlogfile = gzopen("$path/$file", 'ab9');
## append that log entry into the $datedlog.
gzlogfile->gzwrite($log);
$gzlogfile->gzclose();
}
The change log for Compress::Zlib has this entry:
version checking
2.002 29 December 2006
* Fix append mode with gzopen.
rt-cpan.org 24041
I suggest you install the latest version of the module.
HTH,
Rob
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/