# File : Zlib.pm
# Author : Paul Marquess
-# Created : 30 January 2005
-# Version : 1.34
+# Created : 6 September 2005
+# Version : 1.38
#
# Copyright (c) 1995-2005 Paul Marquess. All rights reserved.
# This program is free software; you can redistribute it and/or
require 5.004 ;
require Exporter;
-require DynaLoader;
use AutoLoader;
use Carp ;
use IO::Handle ;
our ($VERSION, @ISA, @EXPORT, $AUTOLOAD);
our ($deflateDefault, $deflateParamsDefault, $inflateDefault);
-$VERSION = "1.34_01" ;
+$VERSION = "1.38" ;
-@ISA = qw(Exporter DynaLoader);
+@ISA = qw(Exporter);
# Items to export into callers namespace by default. Note: do not export
# names by default without a very good reason. Use EXPORT_OK instead.
# Do not simply export all your public functions/methods/constants.
crc32
ZLIB_VERSION
+ ZLIB_VERNUM
DEF_WBITS
OS_CODE
goto &{$AUTOLOAD};
}
-bootstrap Compress::Zlib $VERSION ;
+eval {
+ require XSLoader;
+ XSLoader::load('Compress::Zlib', $VERSION);
+} or do {
+ require DynaLoader;
+ local @ISA = qw(DynaLoader);
+ bootstrap Compress::Zlib $VERSION ;
+} ;
# Preloaded methods go here.
1;
__END__
-=cut
=head1 NAME
=head1 COMPRESS/UNCOMPRESS
Two high-level functions are provided by I<zlib> to perform in-memory
-compression. They are B<compress> and B<uncompress>. Two Perl subs are
-provided which provide similar functionality.
+compression/uncompression of RFC1950 data streams. They are called
+B<compress> and B<uncompress>.
+
+The two Perl subs defined below provide the equivalent
+functionality.
=over 5
=back
+Please note: the two functions defined above are I<not> compatible with
+the Unix commands of the same name.
+
=head1 GZIP INTERFACE
A number of functions are supplied in I<zlib> for reading and writing
If the $crc parameters is C<undef>, the crc value will be reset.
-=head1 ACCESSING ZIP FILES
+=head1 FAQ
+
+=head2 Compatibility with Unix compress/uncompress.
+
+Although C<Compress::Zlib> has a pair of functions called C<compress>
+and C<uncompress>, they are I<not> the same as the Unix programs of the
+same name. The C<Compress::Zlib> library is not compatable with Unix
+C<compress>.
+
+If you have the C<uncompress> program available, you can use this to
+read compressed files
+
+ open F, "uncompress -c $filename |";
+ while (<F>)
+ {
+ ...
+
+If you have the C<gunzip> program available, you can use this to read
+compressed files
+
+ open F, "gunzip -c $filename |";
+ while (<F>)
+ {
+ ...
+
+and this to write compress files if you have the C<compress> program
+available
+
+ open F, "| compress -c $filename ";
+ print F "data";
+ ...
+ close F ;
+
+=head2 Accessing .tar.Z files
+
+The C<Archive::Tar> module can optionally use C<Compress::Zlib> (via
+the C<IO::Zlib> module) to access tar files that have been compressed
+with C<gzip>. Unfortunately tar files compressed with the Unix C<compress>
+utility cannot be read by C<Compress::Zlib> and so cannot be directly
+accesses by C<Archive::Tar>.
+
+If the C<uncompress> or C<gunzip> programs are available, you can use
+one of these workarounds to read C<.tar.Z> files from C<Archive::Tar>
+
+Firstly with C<uncompress>
+
+ use strict;
+ use warnings;
+ use Archive::Tar;
+
+ open F, "uncompress -c $filename |";
+ my $tar = Archive::Tar->new(*F);
+ ...
+
+and this with C<gunzip>
+
+ use strict;
+ use warnings;
+ use Archive::Tar;
+
+ open F, "gunzip -c $filename |";
+ my $tar = Archive::Tar->new(*F);
+ ...
+
+Similarly, if the C<compress> program is available, you can use this to
+write a C<.tar.Z> file
+
+ use strict;
+ use warnings;
+ use Archive::Tar;
+ use IO::File;
+
+ my $fh = newIO::File "| compress -c >$filename";
+ my $tar = Archive::Tar->new();
+ ...
+ $tar->write($fh);
+ $fh->close ;
+
+=head2 Accessing ZIP Files
Although it is possible to use this module to access .zip files, there
is a module on CPAN that will do all the hard work for you. Check out