You are viewing the version of this documentation from Perl 5.22.1. View the latest version

CONTENTS

NAME

IO::Uncompress::Inflate - Read RFC 1950 files/buffers

SYNOPSIS

use IO::Uncompress::Inflate qw(inflate $InflateError) ;

my $status = inflate $input => $output [,OPTS]
    or die "inflate failed: $InflateError\n";

my $z = new IO::Uncompress::Inflate $input [OPTS] 
    or die "inflate failed: $InflateError\n";

$status = $z->read($buffer)
$status = $z->read($buffer, $length)
$status = $z->read($buffer, $length, $offset)
$line = $z->getline()
$char = $z->getc()
$char = $z->ungetc()
$char = $z->opened()

$status = $z->inflateSync()

$data = $z->trailingData()
$status = $z->nextStream()
$data = $z->getHeaderInfo()
$z->tell()
$z->seek($position, $whence)
$z->binmode()
$z->fileno()
$z->eof()
$z->close()

$InflateError ;

# IO::File mode

<$z>
read($z, $buffer);
read($z, $buffer, $length);
read($z, $buffer, $length, $offset);
tell($z)
seek($z, $position, $whence)
binmode($z)
fileno($z)
eof($z)
close($z)

DESCRIPTION

This module provides a Perl interface that allows the reading of files/buffers that conform to RFC 1950.

For writing RFC 1950 files/buffers, see the companion module IO::Compress::Deflate.

Functional Interface

A top-level function, inflate, is provided to carry out "one-shot" uncompression between buffers and/or files. For finer control over the uncompression process, see the "OO Interface" section.

use IO::Uncompress::Inflate qw(inflate $InflateError) ;

inflate $input_filename_or_reference => $output_filename_or_reference [,OPTS] 
    or die "inflate failed: $InflateError\n";

The functional interface needs Perl5.005 or better.

inflate $input_filename_or_reference => $output_filename_or_reference [, OPTS]

inflate expects at least two parameters, $input_filename_or_reference and $output_filename_or_reference.

The $input_filename_or_reference parameter

The parameter, $input_filename_or_reference, is used to define the source of the compressed data.

It can take one of the following forms:

A filename

If the <$input_filename_or_reference> parameter is a simple scalar, it is assumed to be a filename. This file will be opened for reading and the input data will be read from it.

A filehandle

If the $input_filename_or_reference parameter is a filehandle, the input data will be read from it. The string '-' can be used as an alias for standard input.

A scalar reference

If $input_filename_or_reference is a scalar reference, the input data will be read from $$input_filename_or_reference.

An array reference

If $input_filename_or_reference is an array reference, each element in the array must be a filename.

The input data will be read from each file in turn.

The complete array will be walked to ensure that it only contains valid filenames before any data is uncompressed.

An Input FileGlob string

If $input_filename_or_reference is a string that is delimited by the characters "<" and ">" inflate will assume that it is an input fileglob string. The input is the list of files that match the fileglob.

See File::GlobMapper for more details.

If the $input_filename_or_reference parameter is any other type, undef will be returned.

The $output_filename_or_reference parameter

The parameter $output_filename_or_reference is used to control the destination of the uncompressed data. This parameter can take one of these forms.

A filename

If the $output_filename_or_reference parameter is a simple scalar, it is assumed to be a filename. This file will be opened for writing and the uncompressed data will be written to it.

A filehandle

If the $output_filename_or_reference parameter is a filehandle, the uncompressed data will be written to it. The string '-' can be used as an alias for standard output.

A scalar reference

If $output_filename_or_reference is a scalar reference, the uncompressed data will be stored in $$output_filename_or_reference.

An Array Reference

If $output_filename_or_reference is an array reference, the uncompressed data will be pushed onto the array.