📄 gzip.pm
字号:
If C<< Level => Z_BEST_SPEED >> has been specified then XFL is set to 2.If C<< Level => Z_BEST_COMPRESSION >> has been specified then XFL is set to 4.Otherwise XFL is set to 0.=item C<< Strict => 0|1 >>C<Strict> will optionally police the values supplied with other optionsto ensure they are compliant with RFC1952.This option is enabled by default.If C<Strict> is enabled the following behaviour will be policed:=over 5=item * The value supplied with the C<Name> option can only contain ISO 8859-1characters.=item * The value supplied with the C<Comment> option can only contain ISO 8859-1characters plus line-feed.=item *The values supplied with the C<-Name> and C<-Comment> options cannotcontain multiple embedded nulls.=item * If an C<ExtraField> option is specified and it is a simple scalar,it must conform to the sub-field structure as defined in RFC 1952.=item * If an C<ExtraField> option is specified the second byte of the ID will bechecked in each subfield to ensure that it does not contain the reservedvalue 0x00.=backWhen C<Strict> is disabled the following behaviour will be policed:=over 5=item * The value supplied with C<-Name> option can containany character except NULL.=item * The value supplied with C<-Comment> option can contain any characterexcept NULL.=item *The values supplied with the C<-Name> and C<-Comment> options can containmultiple embedded nulls. The string written to the gzip header willconsist of the characters up to, but not including, the first embeddedNULL.=item * If an C<ExtraField> option is specified and it is a simple scalar, thestructure will not be checked. The only error is if the length is too big.=item * The ID header in an C<ExtraField> sub-field can consist of any two bytes.=back=back=head2 ExamplesTODO=head1 Methods =head2 printUsage is $z->print($data) print $z $dataCompresses and outputs the contents of the C<$data> parameter. Thishas the same behaviour as the C<print> built-in.Returns true if successful.=head2 printfUsage is $z->printf($format, $data) printf $z $format, $dataCompresses and outputs the contents of the C<$data> parameter.Returns true if successful.=head2 syswriteUsage is $z->syswrite $data $z->syswrite $data, $length $z->syswrite $data, $length, $offsetCompresses and outputs the contents of the C<$data> parameter.Returns the number of uncompressed bytes written, or C<undef> ifunsuccessful.=head2 writeUsage is $z->write $data $z->write $data, $length $z->write $data, $length, $offsetCompresses and outputs the contents of the C<$data> parameter.Returns the number of uncompressed bytes written, or C<undef> ifunsuccessful.=head2 flushUsage is $z->flush; $z->flush($flush_type);Flushes any pending compressed data to the output file/buffer.This method takes an optional parameter, C<$flush_type>, that controlshow the flushing will be carried out. By default the C<$flush_type>used is C<Z_FINISH>. Other valid values for C<$flush_type> areC<Z_NO_FLUSH>, C<Z_SYNC_FLUSH>, C<Z_FULL_FLUSH> and C<Z_BLOCK>. It isstrongly recommended that you only set the C<flush_type> parameter ifyou fully understand the implications of what it does - overuse of C<flush>can seriously degrade the level of compression achieved. See the C<zlib>documentation for details.Returns true on success.=head2 tellUsage is $z->tell() tell $zReturns the uncompressed file offset.=head2 eofUsage is $z->eof(); eof($z);Returns true if the C<close> method has been called.=head2 seek $z->seek($position, $whence); seek($z, $position, $whence);Provides a sub-set of the C<seek> functionality, with the restrictionthat it is only legal to seek forward in the output file/buffer.It is a fatal error to attempt to seek backward.Empty parts of the file/buffer will have NULL (0x00) bytes written to them.The C<$whence> parameter takes one the usual values, namely SEEK_SET,SEEK_CUR or SEEK_END.Returns 1 on success, 0 on failure.=head2 binmodeUsage is $z->binmode binmode $z ;This is a noop provided for completeness.=head2 opened $z->opened()Returns true if the object currently refers to a opened file/buffer. =head2 autoflush my $prev = $z->autoflush() my $prev = $z->autoflush(EXPR)If the C<$z> object is associated with a file or a filehandle, this methodreturns the current autoflush setting for the underlying filehandle. IfC<EXPR> is present, and is non-zero, it will enable flushing after everywrite/print operation.If C<$z> is associated with a buffer, this method has no effect and alwaysreturns C<undef>.B<Note> that the special variable C<$|> B<cannot> be used to set orretrieve the autoflush setting.=head2 input_line_number $z->input_line_number() $z->input_line_number(EXPR)This method always returns C<undef> when compressing. =head2 fileno $z->fileno() fileno($z)If the C<$z> object is associated with a file or a filehandle, this methodwill return the underlying file descriptor.If the C<$z> object is is associated with a buffer, this method willreturn undef.=head2 close $z->close() ; close $z ;Flushes any pending compressed data and then closes the output file/buffer. For most versions of Perl this method will be automatically invoked ifthe IO::Compress::Gzip object is destroyed (either explicitly or by thevariable with the reference to the object going out of scope). Theexceptions are Perl versions 5.005 through 5.00504 and 5.8.0. Inthese cases, the C<close> method will be called automatically, butnot until global destruction of all live objects when the program isterminating.Therefore, if you want your scripts to be able to run on all versionsof Perl, you should call C<close> explicitly and not rely on automaticclosing.Returns true on success, otherwise 0.If the C<AutoClose> option has been enabled when the IO::Compress::Gzipobject was created, and the object is associated with a file, theunderlying file will also be closed.=head2 newStream([OPTS])Usage is $z->newStream( [OPTS] )Closes the current compressed data stream and starts a new one.OPTS consists of any of the the options that are available when creatingthe C<$z> object.See the L</"Constructor Options"> section for more details.=head2 deflateParamsUsage is $z->deflateParamsTODO=head1 Importing A number of symbolic constants are required by some methods in C<IO::Compress::Gzip>. None are imported by default.=over 5=item :allImports C<gzip>, C<$GzipError> and all symbolicconstants that can be used by C<IO::Compress::Gzip>. Same as doing this use IO::Compress::Gzip qw(gzip $GzipError :constants) ;=item :constantsImport all symbolic constants. Same as doing this use IO::Compress::Gzip qw(:flush :level :strategy) ;=item :flushThese symbolic constants are used by the C<flush> method. Z_NO_FLUSH Z_PARTIAL_FLUSH Z_SYNC_FLUSH Z_FULL_FLUSH Z_FINISH Z_BLOCK=item :levelThese symbolic constants are used by the C<Level> option in the constructor. Z_NO_COMPRESSION Z_BEST_SPEED Z_BEST_COMPRESSION Z_DEFAULT_COMPRESSION=item :strategyThese symbolic constants are used by the C<Strategy> option in the constructor. Z_FILTERED Z_HUFFMAN_ONLY Z_RLE Z_FIXED Z_DEFAULT_STRATEGY =backFor =head1 EXAMPLESTODO=head1 SEE ALSOL<Compress::Zlib>, L<IO::Uncompress::Gunzip>, L<IO::Compress::Deflate>, L<IO::Uncompress::Inflate>, L<IO::Compress::RawDeflate>, L<IO::Uncompress::RawInflate>, L<IO::Compress::Bzip2>, L<IO::Uncompress::Bunzip2>, L<IO::Compress::Lzop>, L<IO::Uncompress::UnLzop>, L<IO::Compress::Lzf>, L<IO::Uncompress::UnLzf>, L<IO::Uncompress::AnyInflate>, L<IO::Uncompress::AnyUncompress>L<Compress::Zlib::FAQ|Compress::Zlib::FAQ>L<File::GlobMapper|File::GlobMapper>, L<Archive::Zip|Archive::Zip>,L<Archive::Tar|Archive::Tar>,L<IO::Zlib|IO::Zlib>For RFC 1950, 1951 and 1952 see F<http://www.faqs.org/rfcs/rfc1950.html>,F<http://www.faqs.org/rfcs/rfc1951.html> andF<http://www.faqs.org/rfcs/rfc1952.html>The I<zlib> compression library was written by Jean-loup GaillyF<gzip@prep.ai.mit.edu> and Mark Adler F<madler@alumni.caltech.edu>.The primary site for the I<zlib> compression library isF<http://www.zlib.org>.The primary site for gzip is F<http://www.gzip.org>.=head1 AUTHORThis module was written by Paul Marquess, F<pmqs@cpan.org>. =head1 MODIFICATION HISTORYSee the Changes file.=head1 COPYRIGHT AND LICENSECopyright (c) 2005-2007 Paul Marquess. All rights reserved.This program is free software; you can redistribute it and/ormodify it under the same terms as Perl itself.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -