Add built local::lib
[catagits/Gitalist.git] / local-lib5 / man / man3 / IO::Compress::Deflate.3pm
CommitLineData
3fea05b9 1.\" Automatically generated by Pod::Man v1.37, Pod::Parser v1.3
2.\"
3.\" Standard preamble:
4.\" ========================================================================
5.de Sh \" Subsection heading
6.br
7.if t .Sp
8.ne 5
9.PP
10\fB\\$1\fR
11.PP
12..
13.de Sp \" Vertical space (when we can't use .PP)
14.if t .sp .5v
15.if n .sp
16..
17.de Vb \" Begin verbatim text
18.ft CW
19.nf
20.ne \\$1
21..
22.de Ve \" End verbatim text
23.ft R
24.fi
25..
26.\" Set up some character translations and predefined strings. \*(-- will
27.\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left
28.\" double quote, and \*(R" will give a right double quote. | will give a
29.\" real vertical bar. \*(C+ will give a nicer C++. Capital omega is used to
30.\" do unbreakable dashes and therefore won't be available. \*(C` and \*(C'
31.\" expand to `' in nroff, nothing in troff, for use with C<>.
32.tr \(*W-|\(bv\*(Tr
33.ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p'
34.ie n \{\
35. ds -- \(*W-
36. ds PI pi
37. if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch
38. if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch
39. ds L" ""
40. ds R" ""
41. ds C` ""
42. ds C' ""
43'br\}
44.el\{\
45. ds -- \|\(em\|
46. ds PI \(*p
47. ds L" ``
48. ds R" ''
49'br\}
50.\"
51.\" If the F register is turned on, we'll generate index entries on stderr for
52.\" titles (.TH), headers (.SH), subsections (.Sh), items (.Ip), and index
53.\" entries marked with X<> in POD. Of course, you'll have to process the
54.\" output yourself in some meaningful fashion.
55.if \nF \{\
56. de IX
57. tm Index:\\$1\t\\n%\t"\\$2"
58..
59. nr % 0
60. rr F
61.\}
62.\"
63.\" For nroff, turn off justification. Always turn off hyphenation; it makes
64.\" way too many mistakes in technical documents.
65.hy 0
66.if n .na
67.\"
68.\" Accent mark definitions (@(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2).
69.\" Fear. Run. Save yourself. No user-serviceable parts.
70. \" fudge factors for nroff and troff
71.if n \{\
72. ds #H 0
73. ds #V .8m
74. ds #F .3m
75. ds #[ \f1
76. ds #] \fP
77.\}
78.if t \{\
79. ds #H ((1u-(\\\\n(.fu%2u))*.13m)
80. ds #V .6m
81. ds #F 0
82. ds #[ \&
83. ds #] \&
84.\}
85. \" simple accents for nroff and troff
86.if n \{\
87. ds ' \&
88. ds ` \&
89. ds ^ \&
90. ds , \&
91. ds ~ ~
92. ds /
93.\}
94.if t \{\
95. ds ' \\k:\h'-(\\n(.wu*8/10-\*(#H)'\'\h"|\\n:u"
96. ds ` \\k:\h'-(\\n(.wu*8/10-\*(#H)'\`\h'|\\n:u'
97. ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'^\h'|\\n:u'
98. ds , \\k:\h'-(\\n(.wu*8/10)',\h'|\\n:u'
99. ds ~ \\k:\h'-(\\n(.wu-\*(#H-.1m)'~\h'|\\n:u'
100. ds / \\k:\h'-(\\n(.wu*8/10-\*(#H)'\z\(sl\h'|\\n:u'
101.\}
102. \" troff and (daisy-wheel) nroff accents
103.ds : \\k:\h'-(\\n(.wu*8/10-\*(#H+.1m+\*(#F)'\v'-\*(#V'\z.\h'.2m+\*(#F'.\h'|\\n:u'\v'\*(#V'
104.ds 8 \h'\*(#H'\(*b\h'-\*(#H'
105.ds o \\k:\h'-(\\n(.wu+\w'\(de'u-\*(#H)/2u'\v'-.3n'\*(#[\z\(de\v'.3n'\h'|\\n:u'\*(#]
106.ds d- \h'\*(#H'\(pd\h'-\w'~'u'\v'-.25m'\f2\(hy\fP\v'.25m'\h'-\*(#H'
107.ds D- D\\k:\h'-\w'D'u'\v'-.11m'\z\(hy\v'.11m'\h'|\\n:u'
108.ds th \*(#[\v'.3m'\s+1I\s-1\v'-.3m'\h'-(\w'I'u*2/3)'\s-1o\s+1\*(#]
109.ds Th \*(#[\s+2I\s-2\h'-\w'I'u*3/5'\v'-.3m'o\v'.3m'\*(#]
110.ds ae a\h'-(\w'a'u*4/10)'e
111.ds Ae A\h'-(\w'A'u*4/10)'E
112. \" corrections for vroff
113.if v .ds ~ \\k:\h'-(\\n(.wu*9/10-\*(#H)'\s-2\u~\d\s+2\h'|\\n:u'
114.if v .ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'\v'-.4m'^\v'.4m'\h'|\\n:u'
115. \" for low resolution devices (crt and lpr)
116.if \n(.H>23 .if \n(.V>19 \
117\{\
118. ds : e
119. ds 8 ss
120. ds o a
121. ds d- d\h'-1'\(ga
122. ds D- D\h'-1'\(hy
123. ds th \o'bp'
124. ds Th \o'LP'
125. ds ae ae
126. ds Ae AE
127.\}
128.rm #[ #] #H #V #F C
129.\" ========================================================================
130.\"
131.IX Title "IO::Compress::Deflate 3"
132.TH IO::Compress::Deflate 3 "2009-11-09" "perl v5.8.7" "User Contributed Perl Documentation"
133.SH "NAME"
134IO::Compress::Deflate \- Write RFC 1950 files/buffers
135.SH "SYNOPSIS"
136.IX Header "SYNOPSIS"
137.Vb 1
138\& use IO::Compress::Deflate qw(deflate $DeflateError) ;
139.Ve
140.PP
141.Vb 2
142\& my $status = deflate $input => $output [,OPTS]
143\& or die "deflate failed: $DeflateError\en";
144.Ve
145.PP
146.Vb 2
147\& my $z = new IO::Compress::Deflate $output [,OPTS]
148\& or die "deflate failed: $DeflateError\en";
149.Ve
150.PP
151.Vb 14
152\& $z\->print($string);
153\& $z\->printf($format, $string);
154\& $z\->write($string);
155\& $z\->syswrite($string [, $length, $offset]);
156\& $z\->flush();
157\& $z\->tell();
158\& $z\->eof();
159\& $z\->seek($position, $whence);
160\& $z\->binmode();
161\& $z\->fileno();
162\& $z\->opened();
163\& $z\->autoflush();
164\& $z\->input_line_number();
165\& $z\->newStream( [OPTS] );
166.Ve
167.PP
168.Vb 1
169\& $z\->deflateParams();
170.Ve
171.PP
172.Vb 1
173\& $z\->close() ;
174.Ve
175.PP
176.Vb 1
177\& $DeflateError ;
178.Ve
179.PP
180.Vb 1
181\& # IO::File mode
182.Ve
183.PP
184.Vb 8
185\& print $z $string;
186\& printf $z $format, $string;
187\& tell $z
188\& eof $z
189\& seek $z, $position, $whence
190\& binmode $z
191\& fileno $z
192\& close $z ;
193.Ve
194.SH "DESCRIPTION"
195.IX Header "DESCRIPTION"
196This module provides a Perl interface that allows writing compressed
197data to files or buffer as defined in \s-1RFC\s0 1950.
198.PP
199For reading \s-1RFC\s0 1950 files/buffers, see the companion module
200IO::Uncompress::Inflate.
201.SH "Functional Interface"
202.IX Header "Functional Interface"
203A top-level function, \f(CW\*(C`deflate\*(C'\fR, is provided to carry out
204\&\*(L"one\-shot\*(R" compression between buffers and/or files. For finer
205control over the compression process, see the \*(L"\s-1OO\s0 Interface\*(R"
206section.
207.PP
208.Vb 1
209\& use IO::Compress::Deflate qw(deflate $DeflateError) ;
210.Ve
211.PP
212.Vb 2
213\& deflate $input => $output [,OPTS]
214\& or die "deflate failed: $DeflateError\en";
215.Ve
216.PP
217The functional interface needs Perl5.005 or better.
218.ie n .Sh "deflate $input\fP => \f(CW$output [, \s-1OPTS\s0]"
219.el .Sh "deflate \f(CW$input\fP => \f(CW$output\fP [, \s-1OPTS\s0]"
220.IX Subsection "deflate $input => $output [, OPTS]"
221\&\f(CW\*(C`deflate\*(C'\fR expects at least two parameters, \f(CW$input\fR and \f(CW$output\fR.
222.PP
223\fIThe \f(CI$input\fI parameter\fR
224.IX Subsection "The $input parameter"
225.PP
226The parameter, \f(CW$input\fR, is used to define the source of
227the uncompressed data.
228.PP
229It can take one of the following forms:
230.IP "A filename" 5
231.IX Item "A filename"
232If the \f(CW$input\fR parameter is a simple scalar, it is assumed to be a
233filename. This file will be opened for reading and the input data
234will be read from it.
235.IP "A filehandle" 5
236.IX Item "A filehandle"
237If the \f(CW$input\fR parameter is a filehandle, the input data will be
238read from it.
239The string '\-' can be used as an alias for standard input.
240.IP "A scalar reference" 5
241.IX Item "A scalar reference"
242If \f(CW$input\fR is a scalar reference, the input data will be read
243from \f(CW$$input\fR.
244.IP "An array reference" 5
245.IX Item "An array reference"
246If \f(CW$input\fR is an array reference, each element in the array must be a
247filename.
248.Sp
249The input data will be read from each file in turn.
250.Sp
251The complete array will be walked to ensure that it only
252contains valid filenames before any data is compressed.
253.IP "An Input FileGlob string" 5
254.IX Item "An Input FileGlob string"
255If \f(CW$input\fR is a string that is delimited by the characters \*(L"<\*(R" and \*(L">\*(R"
256\&\f(CW\*(C`deflate\*(C'\fR will assume that it is an \fIinput fileglob string\fR. The
257input is the list of files that match the fileglob.
258.Sp
259If the fileglob does not match any files ...
260.Sp
261See File::GlobMapper for more details.
262.PP
263If the \f(CW$input\fR parameter is any other type, \f(CW\*(C`undef\*(C'\fR will be returned.
264.PP
265\fIThe \f(CI$output\fI parameter\fR
266.IX Subsection "The $output parameter"
267.PP
268The parameter \f(CW$output\fR is used to control the destination of the
269compressed data. This parameter can take one of these forms.
270.IP "A filename" 5
271.IX Item "A filename"
272If the \f(CW$output\fR parameter is a simple scalar, it is assumed to be a
273filename. This file will be opened for writing and the compressed
274data will be written to it.
275.IP "A filehandle" 5
276.IX Item "A filehandle"
277If the \f(CW$output\fR parameter is a filehandle, the compressed data
278will be written to it.
279The string '\-' can be used as an alias for standard output.
280.IP "A scalar reference" 5
281.IX Item "A scalar reference"
282If \f(CW$output\fR is a scalar reference, the compressed data will be
283stored in \f(CW$$output\fR.
284.IP "An Array Reference" 5
285.IX Item "An Array Reference"
286If \f(CW$output\fR is an array reference, the compressed data will be
287pushed onto the array.
288.IP "An Output FileGlob" 5
289.IX Item "An Output FileGlob"
290If \f(CW$output\fR is a string that is delimited by the characters \*(L"<\*(R" and \*(L">\*(R"
291\&\f(CW\*(C`deflate\*(C'\fR will assume that it is an \fIoutput fileglob string\fR. The
292output is the list of files that match the fileglob.
293.Sp
294When \f(CW$output\fR is an fileglob string, \f(CW$input\fR must also be a fileglob
295string. Anything else is an error.
296.PP
297If the \f(CW$output\fR parameter is any other type, \f(CW\*(C`undef\*(C'\fR will be returned.
298.Sh "Notes"
299.IX Subsection "Notes"
300When \f(CW$input\fR maps to multiple files/buffers and \f(CW$output\fR is a single
301file/buffer the input files/buffers will be stored
302in \f(CW$output\fR as a concatenated series of compressed data streams.
303.Sh "Optional Parameters"
304.IX Subsection "Optional Parameters"
305Unless specified below, the optional parameters for \f(CW\*(C`deflate\*(C'\fR,
306\&\f(CW\*(C`OPTS\*(C'\fR, are the same as those used with the \s-1OO\s0 interface defined in the
307\&\*(L"Constructor Options\*(R" section below.
308.ie n .IP """AutoClose => 0|1""" 5
309.el .IP "\f(CWAutoClose => 0|1\fR" 5
310.IX Item "AutoClose => 0|1"
311This option applies to any input or output data streams to
312\&\f(CW\*(C`deflate\*(C'\fR that are filehandles.
313.Sp
314If \f(CW\*(C`AutoClose\*(C'\fR is specified, and the value is true, it will result in all
315input and/or output filehandles being closed once \f(CW\*(C`deflate\*(C'\fR has
316completed.
317.Sp
318This parameter defaults to 0.
319.ie n .IP """BinModeIn => 0|1""" 5
320.el .IP "\f(CWBinModeIn => 0|1\fR" 5
321.IX Item "BinModeIn => 0|1"
322When reading from a file or filehandle, set \f(CW\*(C`binmode\*(C'\fR before reading.
323.Sp
324Defaults to 0.
325.ie n .IP """Append => 0|1""" 5
326.el .IP "\f(CWAppend => 0|1\fR" 5
327.IX Item "Append => 0|1"
328The behaviour of this option is dependent on the type of output data
329stream.
330.RS 5
331.IP "* A Buffer" 5
332.IX Item "A Buffer"
333If \f(CW\*(C`Append\*(C'\fR is enabled, all compressed data will be append to the end of
334the output buffer. Otherwise the output buffer will be cleared before any
335compressed data is written to it.
336.IP "* A Filename" 5
337.IX Item "A Filename"
338If \f(CW\*(C`Append\*(C'\fR is enabled, the file will be opened in append mode. Otherwise
339the contents of the file, if any, will be truncated before any compressed
340data is written to it.
341.IP "* A Filehandle" 5
342.IX Item "A Filehandle"
343If \f(CW\*(C`Append\*(C'\fR is enabled, the filehandle will be positioned to the end of
344the file via a call to \f(CW\*(C`seek\*(C'\fR before any compressed data is
345written to it. Otherwise the file pointer will not be moved.
346.RE
347.RS 5
348.Sp
349When \f(CW\*(C`Append\*(C'\fR is specified, and set to true, it will \fIappend\fR all compressed
350data to the output data stream.
351.Sp
352So when the output is a filehandle it will carry out a seek to the eof
353before writing any compressed data. If the output is a filename, it will be opened for
354appending. If the output is a buffer, all compressed data will be appened to
355the existing buffer.
356.Sp
357Conversely when \f(CW\*(C`Append\*(C'\fR is not specified, or it is present and is set to
358false, it will operate as follows.
359.Sp
360When the output is a filename, it will truncate the contents of the file
361before writing any compressed data. If the output is a filehandle
362its position will not be changed. If the output is a buffer, it will be
363wiped before any compressed data is output.
364.Sp
365Defaults to 0.
366.RE
367.Sh "Examples"
368.IX Subsection "Examples"
369To read the contents of the file \f(CW\*(C`file1.txt\*(C'\fR and write the compressed
370data to the file \f(CW\*(C`file1.txt.1950\*(C'\fR.
371.PP
372.Vb 3
373\& use strict ;
374\& use warnings ;
375\& use IO::Compress::Deflate qw(deflate $DeflateError) ;
376.Ve
377.PP
378.Vb 3
379\& my $input = "file1.txt";
380\& deflate $input => "$input.1950"
381\& or die "deflate failed: $DeflateError\en";
382.Ve
383.PP
384To read from an existing Perl filehandle, \f(CW$input\fR, and write the
385compressed data to a buffer, \f(CW$buffer\fR.
386.PP
387.Vb 4
388\& use strict ;
389\& use warnings ;
390\& use IO::Compress::Deflate qw(deflate $DeflateError) ;
391\& use IO::File ;
392.Ve
393.PP
394.Vb 5
395\& my $input = new IO::File "<file1.txt"
396\& or die "Cannot open 'file1.txt': $!\en" ;
397\& my $buffer ;
398\& deflate $input => \e$buffer
399\& or die "deflate failed: $DeflateError\en";
400.Ve
401.PP
402To compress all files in the directory \*(L"/my/home\*(R" that match \*(L"*.txt\*(R"
403and store the compressed data in the same directory
404.PP
405.Vb 3
406\& use strict ;
407\& use warnings ;
408\& use IO::Compress::Deflate qw(deflate $DeflateError) ;
409.Ve
410.PP
411.Vb 2
412\& deflate '</my/home/*.txt>' => '<*.1950>'
413\& or die "deflate failed: $DeflateError\en";
414.Ve
415.PP
416and if you want to compress each file one at a time, this will do the trick
417.PP
418.Vb 3
419\& use strict ;
420\& use warnings ;
421\& use IO::Compress::Deflate qw(deflate $DeflateError) ;
422.Ve
423.PP
424.Vb 6
425\& for my $input ( glob "/my/home/*.txt" )
426\& {
427\& my $output = "$input.1950" ;
428\& deflate $input => $output
429\& or die "Error compressing '$input': $DeflateError\en";
430\& }
431.Ve
432.SH "OO Interface"
433.IX Header "OO Interface"
434.Sh "Constructor"
435.IX Subsection "Constructor"
436The format of the constructor for \f(CW\*(C`IO::Compress::Deflate\*(C'\fR is shown below
437.PP
438.Vb 2
439\& my $z = new IO::Compress::Deflate $output [,OPTS]
440\& or die "IO::Compress::Deflate failed: $DeflateError\en";
441.Ve
442.PP
443It returns an \f(CW\*(C`IO::Compress::Deflate\*(C'\fR object on success and undef on failure.
444The variable \f(CW$DeflateError\fR will contain an error message on failure.
445.PP
446If you are running Perl 5.005 or better the object, \f(CW$z\fR, returned from
447IO::Compress::Deflate can be used exactly like an IO::File filehandle.
448This means that all normal output file operations can be carried out
449with \f(CW$z\fR.
450For example, to write to a compressed file/buffer you can use either of
451these forms
452.PP
453.Vb 2
454\& $z\->print("hello world\en");
455\& print $z "hello world\en";
456.Ve
457.PP
458The mandatory parameter \f(CW$output\fR is used to control the destination
459of the compressed data. This parameter can take one of these forms.
460.IP "A filename" 5
461.IX Item "A filename"
462If the \f(CW$output\fR parameter is a simple scalar, it is assumed to be a
463filename. This file will be opened for writing and the compressed data
464will be written to it.
465.IP "A filehandle" 5
466.IX Item "A filehandle"
467If the \f(CW$output\fR parameter is a filehandle, the compressed data will be
468written to it.
469The string '\-' can be used as an alias for standard output.
470.IP "A scalar reference" 5
471.IX Item "A scalar reference"
472If \f(CW$output\fR is a scalar reference, the compressed data will be stored
473in \f(CW$$output\fR.
474.PP
475If the \f(CW$output\fR parameter is any other type, \f(CW\*(C`IO::Compress::Deflate\*(C'\fR::new will
476return undef.
477.Sh "Constructor Options"
478.IX Subsection "Constructor Options"
479\&\f(CW\*(C`OPTS\*(C'\fR is any combination of the following options:
480.ie n .IP """AutoClose => 0|1""" 5
481.el .IP "\f(CWAutoClose => 0|1\fR" 5
482.IX Item "AutoClose => 0|1"
483This option is only valid when the \f(CW$output\fR parameter is a filehandle. If
484specified, and the value is true, it will result in the \f(CW$output\fR being
485closed once either the \f(CW\*(C`close\*(C'\fR method is called or the \f(CW\*(C`IO::Compress::Deflate\*(C'\fR
486object is destroyed.
487.Sp
488This parameter defaults to 0.
489.ie n .IP """Append => 0|1""" 5
490.el .IP "\f(CWAppend => 0|1\fR" 5
491.IX Item "Append => 0|1"
492Opens \f(CW$output\fR in append mode.
493.Sp
494The behaviour of this option is dependent on the type of \f(CW$output\fR.
495.RS 5
496.IP "* A Buffer" 5
497.IX Item "A Buffer"
498If \f(CW$output\fR is a buffer and \f(CW\*(C`Append\*(C'\fR is enabled, all compressed data
499will be append to the end of \f(CW$output\fR. Otherwise \f(CW$output\fR will be
500cleared before any data is written to it.
501.IP "* A Filename" 5
502.IX Item "A Filename"
503If \f(CW$output\fR is a filename and \f(CW\*(C`Append\*(C'\fR is enabled, the file will be
504opened in append mode. Otherwise the contents of the file, if any, will be
505truncated before any compressed data is written to it.
506.IP "* A Filehandle" 5
507.IX Item "A Filehandle"
508If \f(CW$output\fR is a filehandle, the file pointer will be positioned to the
509end of the file via a call to \f(CW\*(C`seek\*(C'\fR before any compressed data is written
510to it. Otherwise the file pointer will not be moved.
511.RE
512.RS 5
513.Sp
514This parameter defaults to 0.
515.RE
516.ie n .IP """Merge => 0|1""" 5
517.el .IP "\f(CWMerge => 0|1\fR" 5
518.IX Item "Merge => 0|1"
519This option is used to compress input data and append it to an existing
520compressed data stream in \f(CW$output\fR. The end result is a single compressed
521data stream stored in \f(CW$output\fR.
522.Sp
523It is a fatal error to attempt to use this option when \f(CW$output\fR is not an
524\&\s-1RFC\s0 1950 data stream.
525.Sp
526There are a number of other limitations with the \f(CW\*(C`Merge\*(C'\fR option:
527.RS 5
528.IP "1" 5
529.IX Item "1"
530This module needs to have been built with zlib 1.2.1 or better to work. A
531fatal error will be thrown if \f(CW\*(C`Merge\*(C'\fR is used with an older version of
532zlib.
533.IP "2" 5
534.IX Item "2"
535If \f(CW$output\fR is a file or a filehandle, it must be seekable.
536.RE
537.RS 5
538.Sp
539This parameter defaults to 0.
540.RE
541.IP "\-Level" 5
542.IX Item "-Level"
543Defines the compression level used by zlib. The value should either be
544a number between 0 and 9 (0 means no compression and 9 is maximum
545compression), or one of the symbolic constants defined below.
546.Sp
547.Vb 4
548\& Z_NO_COMPRESSION
549\& Z_BEST_SPEED
550\& Z_BEST_COMPRESSION
551\& Z_DEFAULT_COMPRESSION
552.Ve
553.Sp
554The default is Z_DEFAULT_COMPRESSION.
555.Sp
556Note, these constants are not imported by \f(CW\*(C`IO::Compress::Deflate\*(C'\fR by default.
557.Sp
558.Vb 3
559\& use IO::Compress::Deflate qw(:strategy);
560\& use IO::Compress::Deflate qw(:constants);
561\& use IO::Compress::Deflate qw(:all);
562.Ve
563.IP "\-Strategy" 5
564.IX Item "-Strategy"
565Defines the strategy used to tune the compression. Use one of the symbolic
566constants defined below.
567.Sp
568.Vb 5
569\& Z_FILTERED
570\& Z_HUFFMAN_ONLY
571\& Z_RLE
572\& Z_FIXED
573\& Z_DEFAULT_STRATEGY
574.Ve
575.Sp
576The default is Z_DEFAULT_STRATEGY.
577.ie n .IP """Strict => 0|1""" 5
578.el .IP "\f(CWStrict => 0|1\fR" 5
579.IX Item "Strict => 0|1"
580This is a placeholder option.
581.Sh "Examples"
582.IX Subsection "Examples"
583\&\s-1TODO\s0
584.SH "Methods"
585.IX Header "Methods"
586.Sh "print"
587.IX Subsection "print"
588Usage is
589.PP
590.Vb 2
591\& $z\->print($data)
592\& print $z $data
593.Ve
594.PP
595Compresses and outputs the contents of the \f(CW$data\fR parameter. This
596has the same behaviour as the \f(CW\*(C`print\*(C'\fR built\-in.
597.PP
598Returns true if successful.
599.Sh "printf"
600.IX Subsection "printf"
601Usage is
602.PP
603.Vb 2
604\& $z\->printf($format, $data)
605\& printf $z $format, $data
606.Ve
607.PP
608Compresses and outputs the contents of the \f(CW$data\fR parameter.
609.PP
610Returns true if successful.
611.Sh "syswrite"
612.IX Subsection "syswrite"
613Usage is
614.PP
615.Vb 3
616\& $z\->syswrite $data
617\& $z\->syswrite $data, $length
618\& $z\->syswrite $data, $length, $offset
619.Ve
620.PP
621Compresses and outputs the contents of the \f(CW$data\fR parameter.
622.PP
623Returns the number of uncompressed bytes written, or \f(CW\*(C`undef\*(C'\fR if
624unsuccessful.
625.Sh "write"
626.IX Subsection "write"
627Usage is
628.PP
629.Vb 3
630\& $z\->write $data
631\& $z\->write $data, $length
632\& $z\->write $data, $length, $offset
633.Ve
634.PP
635Compresses and outputs the contents of the \f(CW$data\fR parameter.
636.PP
637Returns the number of uncompressed bytes written, or \f(CW\*(C`undef\*(C'\fR if
638unsuccessful.
639.Sh "flush"
640.IX Subsection "flush"
641Usage is
642.PP
643.Vb 2
644\& $z\->flush;
645\& $z\->flush($flush_type);
646.Ve
647.PP
648Flushes any pending compressed data to the output file/buffer.
649.PP
650This method takes an optional parameter, \f(CW$flush_type\fR, that controls
651how the flushing will be carried out. By default the \f(CW$flush_type\fR
652used is \f(CW\*(C`Z_FINISH\*(C'\fR. Other valid values for \f(CW$flush_type\fR are
653\&\f(CW\*(C`Z_NO_FLUSH\*(C'\fR, \f(CW\*(C`Z_SYNC_FLUSH\*(C'\fR, \f(CW\*(C`Z_FULL_FLUSH\*(C'\fR and \f(CW\*(C`Z_BLOCK\*(C'\fR. It is
654strongly recommended that you only set the \f(CW\*(C`flush_type\*(C'\fR parameter if
655you fully understand the implications of what it does \- overuse of \f(CW\*(C`flush\*(C'\fR
656can seriously degrade the level of compression achieved. See the \f(CW\*(C`zlib\*(C'\fR
657documentation for details.
658.PP
659Returns true on success.
660.Sh "tell"
661.IX Subsection "tell"
662Usage is
663.PP
664.Vb 2
665\& $z\->tell()
666\& tell $z
667.Ve
668.PP
669Returns the uncompressed file offset.
670.Sh "eof"
671.IX Subsection "eof"
672Usage is
673.PP
674.Vb 2
675\& $z\->eof();
676\& eof($z);
677.Ve
678.PP
679Returns true if the \f(CW\*(C`close\*(C'\fR method has been called.
680.Sh "seek"
681.IX Subsection "seek"
682.Vb 2
683\& $z\->seek($position, $whence);
684\& seek($z, $position, $whence);
685.Ve
686.PP
687Provides a sub-set of the \f(CW\*(C`seek\*(C'\fR functionality, with the restriction
688that it is only legal to seek forward in the output file/buffer.
689It is a fatal error to attempt to seek backward.
690.PP
691Empty parts of the file/buffer will have \s-1NULL\s0 (0x00) bytes written to them.
692.PP
693The \f(CW$whence\fR parameter takes one the usual values, namely \s-1SEEK_SET\s0,
694\&\s-1SEEK_CUR\s0 or \s-1SEEK_END\s0.
695.PP
696Returns 1 on success, 0 on failure.
697.Sh "binmode"
698.IX Subsection "binmode"
699Usage is
700.PP
701.Vb 2
702\& $z\->binmode
703\& binmode $z ;
704.Ve
705.PP
706This is a noop provided for completeness.
707.Sh "opened"
708.IX Subsection "opened"
709.Vb 1
710\& $z\->opened()
711.Ve
712.PP
713Returns true if the object currently refers to a opened file/buffer.
714.Sh "autoflush"
715.IX Subsection "autoflush"
716.Vb 2
717\& my $prev = $z\->autoflush()
718\& my $prev = $z\->autoflush(EXPR)
719.Ve
720.PP
721If the \f(CW$z\fR object is associated with a file or a filehandle, this method
722returns the current autoflush setting for the underlying filehandle. If
723\&\f(CW\*(C`EXPR\*(C'\fR is present, and is non\-zero, it will enable flushing after every
724write/print operation.
725.PP
726If \f(CW$z\fR is associated with a buffer, this method has no effect and always
727returns \f(CW\*(C`undef\*(C'\fR.
728.PP
729\&\fBNote\fR that the special variable \f(CW$|\fR \fBcannot\fR be used to set or
730retrieve the autoflush setting.
731.Sh "input_line_number"
732.IX Subsection "input_line_number"
733.Vb 2
734\& $z\->input_line_number()
735\& $z\->input_line_number(EXPR)
736.Ve
737.PP
738This method always returns \f(CW\*(C`undef\*(C'\fR when compressing.
739.Sh "fileno"
740.IX Subsection "fileno"
741.Vb 2
742\& $z\->fileno()
743\& fileno($z)
744.Ve
745.PP
746If the \f(CW$z\fR object is associated with a file or a filehandle, \f(CW\*(C`fileno\*(C'\fR
747will return the underlying file descriptor. Once the \f(CW\*(C`close\*(C'\fR method is
748called \f(CW\*(C`fileno\*(C'\fR will return \f(CW\*(C`undef\*(C'\fR.
749.PP
750If the \f(CW$z\fR object is is associated with a buffer, this method will return
751\&\f(CW\*(C`undef\*(C'\fR.
752.Sh "close"
753.IX Subsection "close"
754.Vb 2
755\& $z\->close() ;
756\& close $z ;
757.Ve
758.PP
759Flushes any pending compressed data and then closes the output file/buffer.
760.PP
761For most versions of Perl this method will be automatically invoked if
762the IO::Compress::Deflate object is destroyed (either explicitly or by the
763variable with the reference to the object going out of scope). The
764exceptions are Perl versions 5.005 through 5.00504 and 5.8.0. In
765these cases, the \f(CW\*(C`close\*(C'\fR method will be called automatically, but
766not until global destruction of all live objects when the program is
767terminating.
768.PP
769Therefore, if you want your scripts to be able to run on all versions
770of Perl, you should call \f(CW\*(C`close\*(C'\fR explicitly and not rely on automatic
771closing.
772.PP
773Returns true on success, otherwise 0.
774.PP
775If the \f(CW\*(C`AutoClose\*(C'\fR option has been enabled when the IO::Compress::Deflate
776object was created, and the object is associated with a file, the
777underlying file will also be closed.
778.Sh "newStream([\s-1OPTS\s0])"
779.IX Subsection "newStream([OPTS])"
780Usage is
781.PP
782.Vb 1
783\& $z\->newStream( [OPTS] )
784.Ve
785.PP
786Closes the current compressed data stream and starts a new one.
787.PP
788\&\s-1OPTS\s0 consists of any of the the options that are available when creating
789the \f(CW$z\fR object.
790.PP
791See the \*(L"Constructor Options\*(R" section for more details.
792.Sh "deflateParams"
793.IX Subsection "deflateParams"
794Usage is
795.PP
796.Vb 1
797\& $z\->deflateParams
798.Ve
799.PP
800\&\s-1TODO\s0
801.SH "Importing"
802.IX Header "Importing"
803A number of symbolic constants are required by some methods in
804\&\f(CW\*(C`IO::Compress::Deflate\*(C'\fR. None are imported by default.
805.IP ":all" 5
806.IX Item ":all"
807Imports \f(CW\*(C`deflate\*(C'\fR, \f(CW$DeflateError\fR and all symbolic
808constants that can be used by \f(CW\*(C`IO::Compress::Deflate\*(C'\fR. Same as doing this
809.Sp
810.Vb 1
811\& use IO::Compress::Deflate qw(deflate $DeflateError :constants) ;
812.Ve
813.IP ":constants" 5
814.IX Item ":constants"
815Import all symbolic constants. Same as doing this
816.Sp
817.Vb 1
818\& use IO::Compress::Deflate qw(:flush :level :strategy) ;
819.Ve
820.IP ":flush" 5
821.IX Item ":flush"
822These symbolic constants are used by the \f(CW\*(C`flush\*(C'\fR method.
823.Sp
824.Vb 6
825\& Z_NO_FLUSH
826\& Z_PARTIAL_FLUSH
827\& Z_SYNC_FLUSH
828\& Z_FULL_FLUSH
829\& Z_FINISH
830\& Z_BLOCK
831.Ve
832.IP ":level" 5
833.IX Item ":level"
834These symbolic constants are used by the \f(CW\*(C`Level\*(C'\fR option in the constructor.
835.Sp
836.Vb 4
837\& Z_NO_COMPRESSION
838\& Z_BEST_SPEED
839\& Z_BEST_COMPRESSION
840\& Z_DEFAULT_COMPRESSION
841.Ve
842.IP ":strategy" 5
843.IX Item ":strategy"
844These symbolic constants are used by the \f(CW\*(C`Strategy\*(C'\fR option in the constructor.
845.Sp
846.Vb 5
847\& Z_FILTERED
848\& Z_HUFFMAN_ONLY
849\& Z_RLE
850\& Z_FIXED
851\& Z_DEFAULT_STRATEGY
852.Ve
853.SH "EXAMPLES"
854.IX Header "EXAMPLES"
855.Sh "Apache::GZip Revisited"
856.IX Subsection "Apache::GZip Revisited"
857See IO::Compress::FAQ
858.Sh "Working with Net::FTP"
859.IX Subsection "Working with Net::FTP"
860See IO::Compress::FAQ
861.SH "SEE ALSO"
862.IX Header "SEE ALSO"
863Compress::Zlib, IO::Compress::Gzip, IO::Uncompress::Gunzip, IO::Uncompress::Inflate, IO::Compress::RawDeflate, IO::Uncompress::RawInflate, IO::Compress::Bzip2, IO::Uncompress::Bunzip2, IO::Compress::Lzma, IO::Uncompress::UnLzma, IO::Compress::Xz, IO::Uncompress::UnXz, IO::Compress::Lzop, IO::Uncompress::UnLzop, IO::Compress::Lzf, IO::Uncompress::UnLzf, IO::Uncompress::AnyInflate, IO::Uncompress::AnyUncompress
864.PP
865Compress::Zlib::FAQ
866.PP
867File::GlobMapper, Archive::Zip,
868Archive::Tar,
869IO::Zlib
870.PP
871For \s-1RFC\s0 1950, 1951 and 1952 see
872\&\fIhttp://www.faqs.org/rfcs/rfc1950.html\fR,
873\&\fIhttp://www.faqs.org/rfcs/rfc1951.html\fR and
874\&\fIhttp://www.faqs.org/rfcs/rfc1952.html\fR
875.PP
876The \fIzlib\fR compression library was written by Jean-loup Gailly
877\&\fIgzip@prep.ai.mit.edu\fR and Mark Adler \fImadler@alumni.caltech.edu\fR.
878.PP
879The primary site for the \fIzlib\fR compression library is
880\&\fIhttp://www.zlib.org\fR.
881.PP
882The primary site for gzip is \fIhttp://www.gzip.org\fR.
883.SH "AUTHOR"
884.IX Header "AUTHOR"
885This module was written by Paul Marquess, \fIpmqs@cpan.org\fR.
886.SH "MODIFICATION HISTORY"
887.IX Header "MODIFICATION HISTORY"
888See the Changes file.
889.SH "COPYRIGHT AND LICENSE"
890.IX Header "COPYRIGHT AND LICENSE"
891Copyright (c) 2005\-2009 Paul Marquess. All rights reserved.
892.PP
893This program is free software; you can redistribute it and/or
894modify it under the same terms as Perl itself.