|
IO::Filter::* - Generic input/output filters for Perl IO handles. |
IO::Filter::* - Generic input/output filters for Perl IO handles.
use IO::Filter::External; use IO::Filter::bunzip2; use IO::Filter::bzip2; use IO::Filter::gunzip; use IO::Filter::gzip; use IO::Filter::lc; use IO::Filter::sort; use IO::Filter::uc;
$io = # any Perl IO handle, eg. an IO::File or IO::Socket,
# opened for writing
$fio = new IO::Filter::gzip ($io, "w");
$fio->print ("This text will be written gzip-compressed\n",
"to the underlying \$io file or socket.\n");
$fio->close; # also closes underlying $io
$io = # any Perl IO handle opened for reading $fio1 = new IO::Filter::gzip ($io, "r"); $fio2 = new IO::Filter::gunzip ($fio, "r"); # reading from $fio2 is an expensive no-op
IO::Filter::* is a set of filter classes which allow you to
apply filters to ordinary Perl IO handles. In this way you can,
for example, compress data into and out of sockets directly,
perform on-the-fly data transformations and so on. You can
think of filters as being similar in some ways to Unix filter
commands (eg. sort, tr, grep, etc.).
A filter wraps an existing IO handle and gives you back the
same interface (see the IO::Handle(3) manpage), so you can use an
IO::Filter::* object whenever you would use a normal
IO::Handle.
Filters are always unidirectional, meaning that you can use them either in read mode or write mode but not both at the same time.
Note: IO::Filter itself is an abstract superclass. Do not
instantiate objects of type IO::Filter directly. Instead, create
objects of one of the derived classes such as IO::Filter::gzip.
Richard Jones (rich@annexia.org)
Copyright (C) 2001 Richard Jones (rich@annexia.org)
the IO::Filter::External(3) manpage, the IO::Filter::bunzip2(3) manpage, the IO::Filter::bzip2(3) manpage, the IO::Filter::gunzip(3) manpage, the IO::Filter::gzip(3) manpage, the IO::Filter::lc(3) manpage, the IO::Filter::sort(3) manpage, the IO::Filter::uc(3) manpage, the IO::Handle(3) manpage, perl(1).
|
IO::Filter::* - Generic input/output filters for Perl IO handles. |