IO::Compress::* 2.000_13
[p5sagit/p5-mst-13.2.git] / ext / Compress / IO / Zlib / lib / IO / Compress / Zip.pm
CommitLineData
25f0751f 1package IO::Compress::Zip ;
2
3use strict ;
4use warnings;
5use bytes;
6
2b4e0969 7use IO::Compress::Base::Common qw(:Status createSelfTiedObject);
25f0751f 8use IO::Compress::RawDeflate;
9use IO::Compress::Adapter::Deflate;
10use IO::Compress::Adapter::Identity;
e7d45986 11use IO::Compress::Zlib::Extra;
c70c1701 12use IO::Compress::Zip::Constants;
13
25f0751f 14
2b4e0969 15use Compress::Raw::Zlib qw(crc32) ;
16BEGIN
17{
18 eval { require IO::Compress::Adapter::Bzip2;
c70c1701 19 import IO::Compress::Adapter::Bzip2;
2b4e0969 20 require IO::Compress::Bzip2;
c70c1701 21 import IO::Compress::Bzip2;
2b4e0969 22 } ;
23}
24
25
25f0751f 26require Exporter ;
27
28our ($VERSION, @ISA, @EXPORT_OK, %EXPORT_TAGS, $ZipError);
29
e7d45986 30$VERSION = '2.000_13';
25f0751f 31$ZipError = '';
32
33@ISA = qw(Exporter IO::Compress::RawDeflate);
34@EXPORT_OK = qw( $ZipError zip ) ;
35%EXPORT_TAGS = %IO::Compress::RawDeflate::DEFLATE_CONSTANTS ;
36push @{ $EXPORT_TAGS{all} }, @EXPORT_OK ;
2b4e0969 37
38$EXPORT_TAGS{zip_method} = [qw( ZIP_CM_STORE ZIP_CM_DEFLATE ZIP_CM_BZIP2 )];
39push @{ $EXPORT_TAGS{all} }, @{ $EXPORT_TAGS{zip_method} };
40
25f0751f 41Exporter::export_ok_tags('all');
42
25f0751f 43sub new
44{
45 my $class = shift ;
46
47 my $obj = createSelfTiedObject($class, \$ZipError);
48 $obj->_create(undef, @_);
49}
50
51sub zip
52{
53 my $obj = createSelfTiedObject(undef, \$ZipError);
54 return $obj->_def(@_);
55}
56
57sub mkComp
58{
59 my $self = shift ;
60 my $class = shift ;
61 my $got = shift ;
62
63 my ($obj, $errstr, $errno) ;
64
2b4e0969 65 if (*$self->{ZipData}{Method} == ZIP_CM_STORE) {
25f0751f 66 ($obj, $errstr, $errno) = IO::Compress::Adapter::Identity::mkCompObject(
25f0751f 67 $got->value('Level'),
68 $got->value('Strategy')
69 );
70 }
2b4e0969 71 elsif (*$self->{ZipData}{Method} == ZIP_CM_DEFLATE) {
25f0751f 72 ($obj, $errstr, $errno) = IO::Compress::Adapter::Deflate::mkCompObject(
73 $got->value('CRC32'),
74 $got->value('Adler32'),
75 $got->value('Level'),
76 $got->value('Strategy')
77 );
78 }
2b4e0969 79 elsif (*$self->{ZipData}{Method} == ZIP_CM_BZIP2) {
80 ($obj, $errstr, $errno) = IO::Compress::Adapter::Bzip2::mkCompObject(
81 $got->value('BlockSize100K'),
82 $got->value('WorkFactor'),
83 $got->value('Verbosity')
84 );
85 *$self->{ZipData}{CRC32} = crc32(undef);
86 }
25f0751f 87
88 return $self->saveErrorString(undef, $errstr, $errno)
89 if ! defined $obj;
90
91 if (! defined *$self->{ZipData}{StartOffset}) {
e7d45986 92 *$self->{ZipData}{StartOffset} = 0;
93 *$self->{ZipData}{Offset} = new U64 ;
25f0751f 94 }
95
96 return $obj;
97}
98
2b4e0969 99sub reset
100{
101 my $self = shift ;
102
103 *$self->{Compress}->reset();
104 *$self->{ZipData}{CRC32} = Compress::Raw::Zlib::crc32('');
105
106 return STATUS_OK;
107}
108
109sub filterUncompressed
110{
111 my $self = shift ;
25f0751f 112
2b4e0969 113 if (*$self->{ZipData}{Method} == ZIP_CM_DEFLATE) {
114 *$self->{ZipData}{CRC32} = *$self->{Compress}->crc32();
115 }
116 else {
117 *$self->{ZipData}{CRC32} = crc32(${$_[0]}, *$self->{ZipData}{CRC32});
118
119 }
120}
25f0751f 121
122sub mkHeader
123{
124 my $self = shift;
125 my $param = shift ;
126
e7d45986 127 *$self->{ZipData}{StartOffset} = *$self->{ZipData}{Offset}->get32bit() ;
c70c1701 128
25f0751f 129 my $filename = '';
130 $filename = $param->value('Name') || '';
131
132 my $comment = '';
133 $comment = $param->value('Comment') || '';
134
25f0751f 135 my $hdr = '';
136
137 my $time = _unixToDosTime($param->value('Time'));
25f0751f 138
c70c1701 139 my $extra = '';
140 my $ctlExtra = '';
e7d45986 141 my $empty = 0;
142
143 if (*$self->{ZipData}{Zip64}) {
144 $empty = 0xFFFF;
145
146 my $x = '';
147 $x .= pack "V V", 0, 0 ; # uncompressedLength
148 $x .= pack "V V", 0, 0 ; # compressedLength
149 $x .= *$self->{ZipData}{Offset}->getPacked_V64() ; # offset to local hdr
150 #$x .= pack "V ", 0 ; # disk no
151
152 $x = IO::Compress::Zlib::Extra::mkSubField(ZIP_EXTRA_ID_ZIP64, $x);
153 $extra .= $x;
154 $ctlExtra .= $x;
155 }
c70c1701 156
157 if (! $param->value('Minimal')) {
158 if (defined $param->value('exTime'))
159 {
160 $extra .= mkExtendedTime($param->value('MTime'),
161 $param->value('ATime'),
162 $param->value('CTime'));
163
164 $ctlExtra .= mkExtendedTime($param->value('MTime'));
165 }
166
167 # if ( $param->value('UID'))
168 # {
169 # $extra .= mkUnixExtra( $param->value('UID'), $param->value('GID'));
170 # $ctlExtra .= mkUnixExtra();
171 # }
172
173 $extra .= $param->value('ExtraFieldLocal')
174 if defined $param->value('ExtraFieldLocal');
175
176 $ctlExtra .= $param->value('ExtraFieldCentral')
177 if defined $param->value('ExtraFieldCentral');
178 }
179
e7d45986 180
c70c1701 181 my $extAttr = 0;
182 $extAttr = $param->value('Mode') << 16
183 if defined $param->value('Mode') ;
184
185 my $gpFlag = 0 ;
186 $gpFlag |= ZIP_GP_FLAG_STREAMING_MASK
187 if *$self->{ZipData}{Stream} ;
188
2b4e0969 189 my $method = *$self->{ZipData}{Method} ;
190
e7d45986 191 my $version = $ZIP_CM_MIN_VERSIONS{$method};
192 $version = ZIP64_MIN_VERSION
193 if ZIP64_MIN_VERSION > $version && *$self->{ZipData}{Zip64};
194 my $madeBy = ($param->value('OS_Code') << 8) + $version;
195 my $extract = $version;
196
197 *$self->{ZipData}{Version} = $version;
198 *$self->{ZipData}{MadeBy} = $madeBy;
c70c1701 199
200 my $ifa = 0;
201 $ifa |= ZIP_IFA_TEXT_MASK
202 if $param->value('TextFlag');
25f0751f 203
2b4e0969 204 $hdr .= pack "V", ZIP_LOCAL_HDR_SIG ; # signature
25f0751f 205 $hdr .= pack 'v', $extract ; # extract Version & OS
c70c1701 206 $hdr .= pack 'v', $gpFlag ; # general purpose flag (set streaming mode)
25f0751f 207 $hdr .= pack 'v', $method ; # compression method (deflate)
208 $hdr .= pack 'V', $time ; # last mod date/time
209 $hdr .= pack 'V', 0 ; # crc32 - 0 when streaming
e7d45986 210 $hdr .= pack 'V', $empty ; # compressed length - 0 when streaming
211 $hdr .= pack 'V', $empty ; # uncompressed length - 0 when streaming
25f0751f 212 $hdr .= pack 'v', length $filename ; # filename length
c70c1701 213 $hdr .= pack 'v', length $extra ; # extra length
25f0751f 214
215 $hdr .= $filename ;
c70c1701 216 $hdr .= $extra ;
25f0751f 217
218
219 my $ctl = '';
220
2b4e0969 221 $ctl .= pack "V", ZIP_CENTRAL_HDR_SIG ; # signature
c70c1701 222 $ctl .= pack 'v', $madeBy ; # version made by
25f0751f 223 $ctl .= pack 'v', $extract ; # extract Version
c70c1701 224 $ctl .= pack 'v', $gpFlag ; # general purpose flag (streaming mode)
25f0751f 225 $ctl .= pack 'v', $method ; # compression method (deflate)
226 $ctl .= pack 'V', $time ; # last mod date/time
227 $ctl .= pack 'V', 0 ; # crc32
e7d45986 228 $ctl .= pack 'V', $empty ; # compressed length
229 $ctl .= pack 'V', $empty ; # uncompressed length
25f0751f 230 $ctl .= pack 'v', length $filename ; # filename length
c70c1701 231 $ctl .= pack 'v', length $ctlExtra ; # extra length
25f0751f 232 $ctl .= pack 'v', length $comment ; # file comment length
233 $ctl .= pack 'v', 0 ; # disk number start
c70c1701 234 $ctl .= pack 'v', $ifa ; # internal file attributes
235 $ctl .= pack 'V', $extAttr ; # external file attributes
e7d45986 236 if (! *$self->{ZipData}{Zip64}) {
237 $ctl .= pack 'V', *$self->{ZipData}{Offset}->get32bit() ; # offset to local header
238 }
239 else {
240 $ctl .= pack 'V', $empty ; # offset to local header
241 }
25f0751f 242
243 $ctl .= $filename ;
e7d45986 244 *$self->{ZipData}{StartOffset64} = 4 + length $ctl;
c70c1701 245 $ctl .= $ctlExtra ;
25f0751f 246 $ctl .= $comment ;
247
e7d45986 248 *$self->{ZipData}{Offset}->add(length $hdr) ;
25f0751f 249
250 *$self->{ZipData}{CentralHeader} = $ctl;
251
252 return $hdr;
253}
254
255sub mkTrailer
256{
257 my $self = shift ;
258
2b4e0969 259 my $crc32 ;
260 if (*$self->{ZipData}{Method} == ZIP_CM_DEFLATE) {
e7d45986 261 $crc32 = pack "V", *$self->{Compress}->crc32();
2b4e0969 262 }
263 else {
e7d45986 264 $crc32 = pack "V", *$self->{ZipData}{CRC32};
2b4e0969 265 }
266
e7d45986 267 my $ctl = *$self->{ZipData}{CentralHeader} ;
268
269 my $sizes ;
270 if (! *$self->{ZipData}{Zip64}) {
271 $sizes .= *$self->{CompSize}->getPacked_V32() ; # Compressed size
272 $sizes .= *$self->{UnCompSize}->getPacked_V32() ; # Uncompressed size
273 }
274 else {
275 $sizes .= *$self->{CompSize}->getPacked_V64() ; # Compressed size
276 $sizes .= *$self->{UnCompSize}->getPacked_V64() ; # Uncompressed size
277 }
278
279 my $data = $crc32 . $sizes ;
25f0751f 280
25f0751f 281
282 my $hdr = '';
283
284 if (*$self->{ZipData}{Stream}) {
2b4e0969 285 $hdr = pack "V", ZIP_DATA_HDR_SIG ; # signature
25f0751f 286 $hdr .= $data ;
287 }
288 else {
289 $self->writeAt(*$self->{ZipData}{StartOffset} + 14, $data)
290 or return undef;
291 }
292
e7d45986 293 if (! *$self->{ZipData}{Zip64})
294 { substr($ctl, 16, length $data) = $data }
295 else {
296 substr($ctl, 16, length $crc32) = $crc32 ;
297 my $s = *$self->{UnCompSize}->getPacked_V64() ; # Uncompressed size
298 $s .= *$self->{CompSize}->getPacked_V64() ; # Compressed size
299 substr($ctl, *$self->{ZipData}{StartOffset64}, length $s) = $s ;
300 }
25f0751f 301
e7d45986 302 *$self->{ZipData}{Offset}->add(length($hdr));
303 *$self->{ZipData}{Offset}->add( *$self->{CompSize} );
25f0751f 304 push @{ *$self->{ZipData}{CentralDir} }, $ctl ;
305
306 return $hdr;
307}
308
309sub mkFinalTrailer
310{
311 my $self = shift ;
312
313 my $comment = '';
314 $comment = *$self->{ZipData}{ZipComment} ;
315
e7d45986 316 my $cd_offset = *$self->{ZipData}{Offset}->get32bit() ; # offset to start central dir
317
25f0751f 318 my $entries = @{ *$self->{ZipData}{CentralDir} };
319 my $cd = join '', @{ *$self->{ZipData}{CentralDir} };
e7d45986 320 my $cd_len = length $cd ;
321
322 my $z64e = '';
323
324 if ( *$self->{ZipData}{Zip64} ) {
325
326 my $v = *$self->{ZipData}{Version} ;
327 my $mb = *$self->{ZipData}{MadeBy} ;
328 $z64e .= pack 'v', $v ; # Version made by
329 $z64e .= pack 'v', $mb ; # Version to extract
330 $z64e .= pack 'V', 0 ; # number of disk
331 $z64e .= pack 'V', 0 ; # number of disk with central dir
332 $z64e .= U64::pack_V64 $entries ; # entries in central dir on this disk
333 $z64e .= U64::pack_V64 $entries ; # entries in central dir
334 $z64e .= U64::pack_V64 $cd_len ; # size of central dir
335 $z64e .= *$self->{ZipData}{Offset}->getPacked_V64() ; # offset to start central dir
336
337 $z64e = pack("V", ZIP64_END_CENTRAL_REC_HDR_SIG) # signature
338 . U64::pack_V64(length $z64e)
339 . $z64e ;
340
341 *$self->{ZipData}{Offset}->add(length $cd) ;
342
343 $z64e .= pack "V", ZIP64_END_CENTRAL_LOC_HDR_SIG; # signature
344 $z64e .= pack 'V', 0 ; # number of disk with central dir
345 $z64e .= *$self->{ZipData}{Offset}->getPacked_V64() ; # offset to end zip64 central dir
346 $z64e .= pack 'V', 1 ; # Total number of disks
347
348 # TODO - fix these when info-zip 3 is fixed.
349 #$cd_len =
350 #$cd_offset =
351 $entries = 0xFFFF ;
352 }
25f0751f 353
354 my $ecd = '';
2b4e0969 355 $ecd .= pack "V", ZIP_END_CENTRAL_HDR_SIG ; # signature
25f0751f 356 $ecd .= pack 'v', 0 ; # number of disk
e7d45986 357 $ecd .= pack 'v', 0 ; # number of disk with central dir
25f0751f 358 $ecd .= pack 'v', $entries ; # entries in central dir on this disk
359 $ecd .= pack 'v', $entries ; # entries in central dir
e7d45986 360 $ecd .= pack 'V', $cd_len ; # size of central dir
361 $ecd .= pack 'V', $cd_offset ; # offset to start central dir
25f0751f 362 $ecd .= pack 'v', length $comment ; # zipfile comment length
363 $ecd .= $comment;
364
e7d45986 365 return $cd . $z64e . $ecd ;
25f0751f 366}
367
368sub ckParams
369{
370 my $self = shift ;
371 my $got = shift;
372
373 $got->value('CRC32' => 1);
374
375 if (! $got->parsed('Time') ) {
376 # Modification time defaults to now.
377 $got->value('Time' => time) ;
378 }
379
c70c1701 380 if (! $got->parsed('exTime') ) {
381 my $timeRef = $got->value('exTime');
382 if ( defined $timeRef) {
383 return $self->saveErrorString(undef, "exTime not a 3-element array ref")
384 if ref $timeRef ne 'ARRAY' || @$timeRef != 3;
385 }
386
387 $got->value("MTime", $timeRef->[1]);
388 $got->value("ATime", $timeRef->[0]);
389 $got->value("CTime", $timeRef->[2]);
390 }
391
e7d45986 392 *$self->{ZipData}{Zip64} = $got->value('Zip64');
25f0751f 393 *$self->{ZipData}{Stream} = $got->value('Stream');
2b4e0969 394
e7d45986 395 return $self->saveErrorString(undef, "Zip64 only supported if Stream enabled")
396 if *$self->{ZipData}{Zip64} && ! *$self->{ZipData}{Stream} ;
397
2b4e0969 398 my $method = $got->value('Method');
2b4e0969 399 return $self->saveErrorString(undef, "Unknown Method '$method'")
400 if ! defined $ZIP_CM_MIN_VERSIONS{$method};
401
402 return $self->saveErrorString(undef, "Bzip2 not available")
403 if $method == ZIP_CM_BZIP2 and
404 ! defined $IO::Compress::Adapter::Bzip2::VERSION;
405
406 *$self->{ZipData}{Method} = $method;
407
25f0751f 408 *$self->{ZipData}{ZipComment} = $got->value('ZipComment') ;
409
c70c1701 410 for my $name (qw( ExtraFieldLocal ExtraFieldCentral ))
411 {
412 my $data = $got->value($name) ;
413 if (defined $data) {
414 my $bad = IO::Compress::Zlib::Extra::parseExtraField($data, 1, 0) ;
415 return $self->saveErrorString(undef, "Error with $name Parameter: $bad")
416 if $bad ;
417
418 $got->value($name, $data) ;
419 }
420 }
421
2b4e0969 422 return undef
423 if defined $IO::Compress::Bzip2::VERSION
424 and ! IO::Compress::Bzip2::ckParams($self, $got);
25f0751f 425
426 return 1 ;
427}
428
429#sub newHeader
430#{
431# my $self = shift ;
432#
433# return $self->mkHeader(*$self->{Got});
434#}
435
436sub getExtraParams
437{
438 my $self = shift ;
439
440 use IO::Compress::Base::Common qw(:Parse);
441 use Compress::Raw::Zlib qw(Z_DEFLATED Z_DEFAULT_COMPRESSION Z_DEFAULT_STRATEGY);
442
2b4e0969 443 my @Bzip2 = ();
444
445 @Bzip2 = IO::Compress::Bzip2::getExtraParams($self)
446 if defined $IO::Compress::Bzip2::VERSION;
25f0751f 447
448 return (
449 # zlib behaviour
450 $self->getZlibParams(),
451
452 'Stream' => [1, 1, Parse_boolean, 1],
2b4e0969 453 #'Store' => [0, 1, Parse_boolean, 0],
454 'Method' => [0, 1, Parse_unsigned, ZIP_CM_DEFLATE],
25f0751f 455
456# # Zip header fields
c70c1701 457 'Minimal' => [0, 1, Parse_boolean, 0],
e7d45986 458 'Zip64' => [0, 1, Parse_boolean, 0],
25f0751f 459 'Comment' => [0, 1, Parse_any, ''],
460 'ZipComment'=> [0, 1, Parse_any, ''],
461 'Name' => [0, 1, Parse_any, ''],
462 'Time' => [0, 1, Parse_any, undef],
c70c1701 463 'exTime' => [0, 1, Parse_any, undef],
25f0751f 464 'OS_Code' => [0, 1, Parse_unsigned, $Compress::Raw::Zlib::gzip_os_code],
465
c70c1701 466 'TextFlag' => [0, 1, Parse_boolean, 0],
467 'ExtraFieldLocal' => [0, 1, Parse_any, undef],
468 'ExtraFieldCentral'=> [0, 1, Parse_any, undef],
2b4e0969 469
470 @Bzip2,
25f0751f 471 );
472}
473
474sub getInverseClass
475{
476 return ('IO::Uncompress::Unzip',
477 \$IO::Uncompress::Unzip::UnzipError);
478}
479
480sub getFileInfo
481{
482 my $self = shift ;
483 my $params = shift;
484 my $filename = shift ;
485
c70c1701 486 my ($mode, $uid, $gid, $atime, $mtime, $ctime)
487 = (stat($filename))[2, 4,5, 8,9,10] ;
25f0751f 488
489 $params->value('Name' => $filename)
490 if ! $params->parsed('Name') ;
491
c70c1701 492 $params->value('Time' => $mtime)
25f0751f 493 if ! $params->parsed('Time') ;
494
c70c1701 495 if ( ! $params->parsed('exTime'))
496 {
497 $params->value('MTime' => $mtime) ;
498 $params->value('ATime' => $atime) ;
499 $params->value('CTime' => $ctime) ;
500 }
501
502 $params->value('Mode' => $mode) ;
503
504 $params->value('UID' => $uid) ;
505 $params->value('GID' => $gid) ;
25f0751f 506
507}
508
c70c1701 509sub mkExtendedTime
510{
511 # order expected is m, a, c
512
513 my $times = '';
514 my $bit = 1 ;
515 my $flags = 0;
516
517 for my $time (@_)
518 {
519 if (defined $time)
520 {
521 $flags |= $bit;
522 $times .= pack("V", $time);
523 }
524
525 $bit <<= 1 ;
526 }
527
528 #return "UT" . pack("v C", length($times) + 1, $flags) . $times;
529 return IO::Compress::Zlib::Extra::mkSubField(ZIP_EXTRA_ID_EXT_TIMESTAMP,
530 pack("C", $flags) . $times);
531}
532
533sub mkUnixExtra
534{
535 my $ids = '';
536 for my $id (@_)
537 {
538 $ids .= pack("v", $id);
539 }
540
541 #return "Ux" . pack("v", length $ids) . $ids;
542 return IO::Compress::Zlib::Extra::mkSubField(ZIP_EXTRA_ID_INFO_ZIP_UNIX, $ids);
543}
544
545
25f0751f 546# from Archive::Zip
547sub _unixToDosTime # Archive::Zip::Member
548{
549 my $time_t = shift;
550 # TODO - add something to cope with unix time < 1980
551 my ( $sec, $min, $hour, $mday, $mon, $year ) = localtime($time_t);
552 my $dt = 0;
553 $dt += ( $sec >> 1 );
554 $dt += ( $min << 5 );
555 $dt += ( $hour << 11 );
556 $dt += ( $mday << 16 );
557 $dt += ( ( $mon + 1 ) << 21 );
558 $dt += ( ( $year - 80 ) << 25 );
559 return $dt;
560}
561
5621;
563
564__END__
565
566=head1 NAME
567
568
cb7abd7f 569
570IO::Compress::Zip - Write zip files/buffers
571
25f0751f 572
573
574=head1 SYNOPSIS
575
576 use IO::Compress::Zip qw(zip $ZipError) ;
577
578
579 my $status = zip $input => $output [,OPTS]
580 or die "zip failed: $ZipError\n";
581
582 my $z = new IO::Compress::Zip $output [,OPTS]
583 or die "zip failed: $ZipError\n";
584
585 $z->print($string);
586 $z->printf($format, $string);
587 $z->write($string);
588 $z->syswrite($string [, $length, $offset]);
589 $z->flush();
590 $z->tell();
591 $z->eof();
592 $z->seek($position, $whence);
593 $z->binmode();
594 $z->fileno();
595 $z->opened();
596 $z->autoflush();
597 $z->input_line_number();
598 $z->newStream( [OPTS] );
599
600 $z->deflateParams();
601
602 $z->close() ;
603
604 $ZipError ;
605
606 # IO::File mode
607
608 print $z $string;
609 printf $z $format, $string;
610 tell $z
611 eof $z
612 seek $z, $position, $whence
613 binmode $z
614 fileno $z
615 close $z ;
616
617
618=head1 DESCRIPTION
619
620
621
622B<WARNING -- This is a Beta release>.
623
624=over 5
625
626=item * DO NOT use in production code.
627
628=item * The documentation is incomplete in places.
629
630=item * Parts of the interface defined here are tentative.
631
632=item * Please report any problems you find.
633
634=back
635
636
637
638
639This module provides a Perl interface that allows writing zip
640compressed data to files or buffer.
641
642
643
644
645
646
647
cb7abd7f 648Note that IO::Compress::Zip is not intended to be a replacement for the module
25f0751f 649C<Archive::Zip>.
cb7abd7f 650
25f0751f 651The primary aim of this module is not as an archiver, but to provide
652streaming write access to zip file files and buffers.
653
654
655
656For reading zip files/buffers, see the companion module
657L<IO::Uncompress::Unzip|IO::Uncompress::Unzip>.
658
659
660=head1 Functional Interface
661
662A top-level function, C<zip>, is provided to carry out
663"one-shot" compression between buffers and/or files. For finer
664control over the compression process, see the L</"OO Interface">
665section.
666
667 use IO::Compress::Zip qw(zip $ZipError) ;
668
669 zip $input => $output [,OPTS]
670 or die "zip failed: $ZipError\n";
671
672
673
674The functional interface needs Perl5.005 or better.
675
676
677=head2 zip $input => $output [, OPTS]
678
679
680C<zip> expects at least two parameters, C<$input> and C<$output>.
681
682=head3 The C<$input> parameter
683
684The parameter, C<$input>, is used to define the source of
685the uncompressed data.
686
687It can take one of the following forms:
688
689=over 5
690
691=item A filename
692
693If the C<$input> parameter is a simple scalar, it is assumed to be a
694filename. This file will be opened for reading and the input data
695will be read from it.
696
697=item A filehandle
698
699If the C<$input> parameter is a filehandle, the input data will be
700read from it.
701The string '-' can be used as an alias for standard input.
702
703=item A scalar reference
704
705If C<$input> is a scalar reference, the input data will be read
706from C<$$input>.
707
708=item An array reference
709
710If C<$input> is an array reference, each element in the array must be a
711filename.
712
713The input data will be read from each file in turn.
714
715The complete array will be walked to ensure that it only
716contains valid filenames before any data is compressed.
717
718
719
720=item An Input FileGlob string
721
722If C<$input> is a string that is delimited by the characters "<" and ">"
723C<zip> will assume that it is an I<input fileglob string>. The
724input is the list of files that match the fileglob.
725
726If the fileglob does not match any files ...
727
728See L<File::GlobMapper|File::GlobMapper> for more details.
729
730
731=back
732
733If the C<$input> parameter is any other type, C<undef> will be returned.
734
735
25f0751f 736In addition, if C<$input> is a simple filename, the default values for
c70c1701 737the C<Name>, C<Time> and C<exTime> options will be sourced from that file.
25f0751f 738
739If you do not want to use these defaults they can be overridden by
c70c1701 740explicitly setting the C<Name>, C<Time> and C<exTime> options or by setting the
25f0751f 741C<Minimal> parameter.
742
743
744
745=head3 The C<$output> parameter
746
747The parameter C<$output> is used to control the destination of the
748compressed data. This parameter can take one of these forms.
749
750=over 5
751
752=item A filename
753
754If the C<$output> parameter is a simple scalar, it is assumed to be a
755filename. This file will be opened for writing and the compressed
756data will be written to it.
757
758=item A filehandle
759
760If the C<$output> parameter is a filehandle, the compressed data
761will be written to it.
762The string '-' can be used as an alias for standard output.
763
764
765=item A scalar reference
766
767If C<$output> is a scalar reference, the compressed data will be
768stored in C<$$output>.
769
770
771
772=item An Array Reference
773
774If C<$output> is an array reference, the compressed data will be
775pushed onto the array.
776
777=item An Output FileGlob
778
779If C<$output> is a string that is delimited by the characters "<" and ">"
780C<zip> will assume that it is an I<output fileglob string>. The
781output is the list of files that match the fileglob.
782
783When C<$output> is an fileglob string, C<$input> must also be a fileglob
784string. Anything else is an error.
785
786=back
787
788If the C<$output> parameter is any other type, C<undef> will be returned.
789
790
791
792=head2 Notes
793
c70c1701 794
795
25f0751f 796When C<$input> maps to multiple files/buffers and C<$output> is a single
c70c1701 797file/buffer the input files/buffers will each be stored
798in C<$output> as a distinct entry.
799
800
801
25f0751f 802
803
804
805=head2 Optional Parameters
806
807Unless specified below, the optional parameters for C<zip>,
808C<OPTS>, are the same as those used with the OO interface defined in the
809L</"Constructor Options"> section below.
810
811=over 5
812
e7d45986 813=item C<< AutoClose => 0|1 >>
25f0751f 814
815This option applies to any input or output data streams to
816C<zip> that are filehandles.
817
818If C<AutoClose> is specified, and the value is true, it will result in all
819input and/or output filehandles being closed once C<zip> has
820completed.
821
822This parameter defaults to 0.
823
824
e7d45986 825=item C<< BinModeIn => 0|1 >>
25f0751f 826
827When reading from a file or filehandle, set C<binmode> before reading.
828
829Defaults to 0.
830
831
832
833
834
e7d45986 835=item C<< Append => 0|1 >>
25f0751f 836
837TODO
838
839
840=back
841
842
843
844=head2 Examples
845
846To read the contents of the file C<file1.txt> and write the compressed
847data to the file C<file1.txt.zip>.
848
849 use strict ;
850 use warnings ;
851 use IO::Compress::Zip qw(zip $ZipError) ;
852
853 my $input = "file1.txt";
854 zip $input => "$input.zip"
855 or die "zip failed: $ZipError\n";
856
857
858To read from an existing Perl filehandle, C<$input>, and write the
859compressed data to a buffer, C<$buffer>.
860
861 use strict ;
862 use warnings ;
863 use IO::Compress::Zip qw(zip $ZipError) ;
864 use IO::File ;
865
866 my $input = new IO::File "<file1.txt"
867 or die "Cannot open 'file1.txt': $!\n" ;
868 my $buffer ;
869 zip $input => \$buffer
870 or die "zip failed: $ZipError\n";
871
872To compress all files in the directory "/my/home" that match "*.txt"
873and store the compressed data in the same directory
874
875 use strict ;
876 use warnings ;
877 use IO::Compress::Zip qw(zip $ZipError) ;
878
879 zip '</my/home/*.txt>' => '<*.zip>'
880 or die "zip failed: $ZipError\n";
881
882and if you want to compress each file one at a time, this will do the trick
883
884 use strict ;
885 use warnings ;
886 use IO::Compress::Zip qw(zip $ZipError) ;
887
888 for my $input ( glob "/my/home/*.txt" )
889 {
890 my $output = "$input.zip" ;
891 zip $input => $output
892 or die "Error compressing '$input': $ZipError\n";
893 }
894
895
896=head1 OO Interface
897
898=head2 Constructor
899
900The format of the constructor for C<IO::Compress::Zip> is shown below
901
902 my $z = new IO::Compress::Zip $output [,OPTS]
903 or die "IO::Compress::Zip failed: $ZipError\n";
904
905It returns an C<IO::Compress::Zip> object on success and undef on failure.
906The variable C<$ZipError> will contain an error message on failure.
907
908If you are running Perl 5.005 or better the object, C<$z>, returned from
909IO::Compress::Zip can be used exactly like an L<IO::File|IO::File> filehandle.
910This means that all normal output file operations can be carried out
911with C<$z>.
912For example, to write to a compressed file/buffer you can use either of
913these forms
914
915 $z->print("hello world\n");
916 print $z "hello world\n";
917
918The mandatory parameter C<$output> is used to control the destination
919of the compressed data. This parameter can take one of these forms.
920
921=over 5
922
923=item A filename
924
925If the C<$output> parameter is a simple scalar, it is assumed to be a
926filename. This file will be opened for writing and the compressed data
927will be written to it.
928
929=item A filehandle
930
931If the C<$output> parameter is a filehandle, the compressed data will be
932written to it.
933The string '-' can be used as an alias for standard output.
934
935
936=item A scalar reference
937
938If C<$output> is a scalar reference, the compressed data will be stored
939in C<$$output>.
940
941=back
942
943If the C<$output> parameter is any other type, C<IO::Compress::Zip>::new will
944return undef.
945
946=head2 Constructor Options
947
948C<OPTS> is any combination of the following options:
949
950=over 5
951
e7d45986 952=item C<< AutoClose => 0|1 >>
25f0751f 953
954This option is only valid when the C<$output> parameter is a filehandle. If
955specified, and the value is true, it will result in the C<$output> being
956closed once either the C<close> method is called or the C<IO::Compress::Zip>
957object is destroyed.
958
959This parameter defaults to 0.
960
e7d45986 961=item C<< Append => 0|1 >>
25f0751f 962
963Opens C<$output> in append mode.
964
965The behaviour of this option is dependent on the type of C<$output>.
966
967=over 5
968
969=item * A Buffer
970
971If C<$output> is a buffer and C<Append> is enabled, all compressed data
972will be append to the end if C<$output>. Otherwise C<$output> will be
973cleared before any data is written to it.
974
975=item * A Filename
976
977If C<$output> is a filename and C<Append> is enabled, the file will be
978opened in append mode. Otherwise the contents of the file, if any, will be
979truncated before any compressed data is written to it.
980
981=item * A Filehandle
982
983If C<$output> is a filehandle, the file pointer will be positioned to the
984end of the file via a call to C<seek> before any compressed data is written
985to it. Otherwise the file pointer will not be moved.
986
987=back
988
989This parameter defaults to 0.
990
991
992
e7d45986 993=item C<< Name => $string >>
2b4e0969 994
995Stores the contents of C<$string> in the zip filename header field. If
996C<Name> is not specified, no zip filename field will be created.
997
e7d45986 998=item C<< Time => $number >>
2b4e0969 999
1000Sets the last modified time field in the zip header to $number.
1001
1002This field defaults to the time the C<IO::Compress::Zip> object was created
1003if this option is not specified.
1004
e7d45986 1005=item C<< exTime => [$atime, $mtime, $ctime] >>
c70c1701 1006
1007This option expects an array reference with exactly three elements:
1008C<$atime>, C<mtime> and C<$ctime>. These correspond to the last access
1009time, last modification time and creation time respectively.
1010
1011It uses these values to set the extended timestamp field in the local zip
1012header to the three values, $atime, $mtime, $ctime and sets the extended
1013timestamp field in the central zip header to C<$mtime>.
1014
1015If the C<Minimal> option is set to true, this option will be ignored.
1016
1017By default no extended time field is created.
1018
e7d45986 1019=item C<< Comment => $comment >>
c70c1701 1020
1021Stores the contents of C<$comment> in the Central File Header of
1022the zip file.
1023
1024By default, no comment field is written to the zip file.
1025
e7d45986 1026=item C<< ZipComment => $comment >>
c70c1701 1027
1028Stores the contents of C<$comment> in the End of Central Directory record
1029of the zip file.
1030
1031By default, no comment field is written to the zip file.
1032
e7d45986 1033=item C<< Method => $method >>
2b4e0969 1034
1035Controls which compression method is used. At present three compression
1036methods are supported, namely Store (no compression at all), Deflate and
1037Bzip2.
1038
1039The symbols, ZIP_CM_STORE, ZIP_CM_DEFLATE and ZIP_CM_BZIP2 are used to
1040select the compression method.
1041
1042These constants are not imported by C<IO::Compress::Zip> by default.
1043
1044 use IO::Compress::Zip qw(:zip_method);
1045 use IO::Compress::Zip qw(:constants);
1046 use IO::Compress::Zip qw(:all);
1047
1048Note that to create Bzip2 content, the module C<IO::Compress::Bzip2> must
1049be installed. A fatal error will be thrown if you attempt to create Bzip2
1050content when C<IO::Compress::Bzip2> is not available.
1051
1052The default method is ZIP_CM_DEFLATE.
1053
e7d45986 1054=item C<< Stream => 0|1 >>
2b4e0969 1055
1056This option controls whether the zip file/buffer output is created in
1057streaming mode.
1058
c70c1701 1059Note that when outputting to a file with streaming mode disabled (C<Stream>
1060is 0), the output file must be seekable.
1061
2b4e0969 1062The default is 1.
1063
e7d45986 1064=item C<< TextFlag => 0|1 >>
c70c1701 1065
1066This parameter controls the setting of a bit in the zip central header. It
1067is used to signal that the data stored in the zip file/buffer is probably
1068text.
1069
1070The default is 0.
1071
e7d45986 1072=item C<< ExtraFieldLocal => $data >>
1073=item C<< ExtraFieldCentral => $data >>
c70c1701 1074
1075These options allows additional metadata to be stored in the local and
1076central headers in the zip file/buffer.
1077
1078An extra field consists of zero or more subfields. Each subfield consists
1079of a two byte header followed by the subfield data.
1080
1081The list of subfields can be supplied in any of the following formats
1082
1083 ExtraFieldLocal => [$id1, $data1,
1084 $id2, $data2,
1085 ...
1086 ]
1087
1088 ExtraFieldLocal => [ [$id1 => $data1],
1089 [$id2 => $data2],
1090 ...
1091 ]
1092
1093 ExtraFieldLocal => { $id1 => $data1,
1094 $id2 => $data2,
1095 ...
1096 }
1097
1098Where C<$id1>, C<$id2> are two byte subfield ID's.
1099
1100If you use the hash syntax, you have no control over the order in which
1101the ExtraSubFields are stored, plus you cannot have SubFields with
1102duplicate ID.
1103
1104Alternatively the list of subfields can by supplied as a scalar, thus
1105
1106 ExtraField => $rawdata
1107
1108
1109
1110If the C<Minimal> option is set to true, this option will be ignored.
1111
1112The maximum size of an extra field 65535 bytes.
1113
e7d45986 1114=item C<< Minimal => 1|0 >>
c70c1701 1115
1116If specified, this option will disable the creation of all extended fields
1117in the zip local and central headers.
1118
1119This parameter defaults to 0.
1120
e7d45986 1121=item C<< BlockSize100K => number >>
2b4e0969 1122
1123Specify the number of 100K blocks bzip2 uses during compression.
1124
1125Valid values are from 1 to 9, where 9 is best compression.
1126
1127This option is only valid if the C<Method> is ZIP_CM_BZIP2. It is ignored
1128otherwise.
1129
1130The default is 1.
1131
e7d45986 1132=item C<< WorkFactor => number >>
2b4e0969 1133
1134Specifies how much effort bzip2 should take before resorting to a slower
1135fallback compression algorithm.
1136
1137Valid values range from 0 to 250, where 0 means use the default value 30.
1138
1139This option is only valid if the C<Method> is ZIP_CM_BZIP2. It is ignored
1140otherwise.
1141
1142The default is 0.
1143
25f0751f 1144
1145
1146
1147=item -Level
1148
1149Defines the compression level used by zlib. The value should either be
1150a number between 0 and 9 (0 means no compression and 9 is maximum
1151compression), or one of the symbolic constants defined below.
1152
1153 Z_NO_COMPRESSION
1154 Z_BEST_SPEED
1155 Z_BEST_COMPRESSION
1156 Z_DEFAULT_COMPRESSION
1157
1158The default is Z_DEFAULT_COMPRESSION.
1159
1160Note, these constants are not imported by C<IO::Compress::Zip> by default.
1161
1162 use IO::Compress::Zip qw(:strategy);
1163 use IO::Compress::Zip qw(:constants);
1164 use IO::Compress::Zip qw(:all);
1165
1166=item -Strategy
1167
1168Defines the strategy used to tune the compression. Use one of the symbolic
1169constants defined below.
1170
1171 Z_FILTERED
1172 Z_HUFFMAN_ONLY
1173 Z_RLE
1174 Z_FIXED
1175 Z_DEFAULT_STRATEGY
1176
1177The default is Z_DEFAULT_STRATEGY.
1178
1179
1180
1181
1182
1183
e7d45986 1184=item C<< Strict => 0|1 >>
25f0751f 1185
1186
1187
1188This is a placeholder option.
1189
1190
1191
1192=back
1193
1194=head2 Examples
1195
1196TODO
1197
1198=head1 Methods
1199
1200=head2 print
1201
1202Usage is
1203
1204 $z->print($data)
1205 print $z $data
1206
1207Compresses and outputs the contents of the C<$data> parameter. This
1208has the same behaviour as the C<print> built-in.
1209
1210Returns true if successful.
1211
1212=head2 printf
1213
1214Usage is
1215
1216 $z->printf($format, $data)
1217 printf $z $format, $data
1218
1219Compresses and outputs the contents of the C<$data> parameter.
1220
1221Returns true if successful.
1222
1223=head2 syswrite
1224
1225Usage is
1226
1227 $z->syswrite $data
1228 $z->syswrite $data, $length
1229 $z->syswrite $data, $length, $offset
1230
1231Compresses and outputs the contents of the C<$data> parameter.
1232
1233Returns the number of uncompressed bytes written, or C<undef> if
1234unsuccessful.
1235
1236=head2 write
1237
1238Usage is
1239
1240 $z->write $data
1241 $z->write $data, $length
1242 $z->write $data, $length, $offset
1243
1244Compresses and outputs the contents of the C<$data> parameter.
1245
1246Returns the number of uncompressed bytes written, or C<undef> if
1247unsuccessful.
1248
1249=head2 flush
1250
1251Usage is
1252
1253
1254 $z->flush;
1255 $z->flush($flush_type);
1256
1257
1258Flushes any pending compressed data to the output file/buffer.
1259
1260
1261This method takes an optional parameter, C<$flush_type>, that controls
1262how the flushing will be carried out. By default the C<$flush_type>
1263used is C<Z_FINISH>. Other valid values for C<$flush_type> are
1264C<Z_NO_FLUSH>, C<Z_SYNC_FLUSH>, C<Z_FULL_FLUSH> and C<Z_BLOCK>. It is
1265strongly recommended that you only set the C<flush_type> parameter if
1266you fully understand the implications of what it does - overuse of C<flush>
1267can seriously degrade the level of compression achieved. See the C<zlib>
1268documentation for details.
1269
1270
1271Returns true on success.
1272
1273
1274=head2 tell
1275
1276Usage is
1277
1278 $z->tell()
1279 tell $z
1280
1281Returns the uncompressed file offset.
1282
1283=head2 eof
1284
1285Usage is
1286
1287 $z->eof();
1288 eof($z);
1289
1290
1291
1292Returns true if the C<close> method has been called.
1293
1294
1295
1296=head2 seek
1297
1298 $z->seek($position, $whence);
1299 seek($z, $position, $whence);
1300
1301
1302
1303
1304Provides a sub-set of the C<seek> functionality, with the restriction
1305that it is only legal to seek forward in the output file/buffer.
1306It is a fatal error to attempt to seek backward.
1307
1308Empty parts of the file/buffer will have NULL (0x00) bytes written to them.
1309
1310
1311
1312The C<$whence> parameter takes one the usual values, namely SEEK_SET,
1313SEEK_CUR or SEEK_END.
1314
1315Returns 1 on success, 0 on failure.
1316
1317=head2 binmode
1318
1319Usage is
1320
1321 $z->binmode
1322 binmode $z ;
1323
1324This is a noop provided for completeness.
1325
1326=head2 opened
1327
1328 $z->opened()
1329
1330Returns true if the object currently refers to a opened file/buffer.
1331
1332=head2 autoflush
1333
1334 my $prev = $z->autoflush()
1335 my $prev = $z->autoflush(EXPR)
1336
1337If the C<$z> object is associated with a file or a filehandle, this method
1338returns the current autoflush setting for the underlying filehandle. If
1339C<EXPR> is present, and is non-zero, it will enable flushing after every
1340write/print operation.
1341
1342If C<$z> is associated with a buffer, this method has no effect and always
1343returns C<undef>.
1344
1345B<Note> that the special variable C<$|> B<cannot> be used to set or
1346retrieve the autoflush setting.
1347
1348=head2 input_line_number
1349
1350 $z->input_line_number()
1351 $z->input_line_number(EXPR)
1352
1353
1354This method always returns C<undef> when compressing.
1355
1356
1357
1358=head2 fileno
1359
1360 $z->fileno()
1361 fileno($z)
1362
1363If the C<$z> object is associated with a file or a filehandle, this method
1364will return the underlying file descriptor.
1365
1366If the C<$z> object is is associated with a buffer, this method will
1367return undef.
1368
1369=head2 close
1370
1371 $z->close() ;
1372 close $z ;
1373
1374
1375
1376Flushes any pending compressed data and then closes the output file/buffer.
1377
1378
1379
1380For most versions of Perl this method will be automatically invoked if
1381the IO::Compress::Zip object is destroyed (either explicitly or by the
1382variable with the reference to the object going out of scope). The
1383exceptions are Perl versions 5.005 through 5.00504 and 5.8.0. In
1384these cases, the C<close> method will be called automatically, but
1385not until global destruction of all live objects when the program is
1386terminating.
1387
1388Therefore, if you want your scripts to be able to run on all versions
1389of Perl, you should call C<close> explicitly and not rely on automatic
1390closing.
1391
1392Returns true on success, otherwise 0.
1393
1394If the C<AutoClose> option has been enabled when the IO::Compress::Zip
1395object was created, and the object is associated with a file, the
1396underlying file will also be closed.
1397
1398
1399
1400
1401=head2 newStream([OPTS])
1402
1403Usage is
1404
1405 $z->newStream( [OPTS] )
1406
1407Closes the current compressed data stream and starts a new one.
1408
e7d45986 1409OPTS consists of any of the the options that are available when creating
1410the C<$z> object.
25f0751f 1411
e7d45986 1412See the L</"Constructor Options"> section for more details.
25f0751f 1413
1414
1415=head2 deflateParams
1416
1417Usage is
1418
1419 $z->deflateParams
1420
1421TODO
1422
1423
1424=head1 Importing
1425
1426
1427A number of symbolic constants are required by some methods in
1428C<IO::Compress::Zip>. None are imported by default.
1429
1430
1431
1432=over 5
1433
1434=item :all
1435
1436
1437Imports C<zip>, C<$ZipError> and all symbolic
1438constants that can be used by C<IO::Compress::Zip>. Same as doing this
1439
1440 use IO::Compress::Zip qw(zip $ZipError :constants) ;
1441
1442=item :constants
1443
1444Import all symbolic constants. Same as doing this
1445
2b4e0969 1446
1447 use IO::Compress::Zip qw(:flush :level :strategy :zip_method) ;
1448
25f0751f 1449
1450=item :flush
1451
1452These symbolic constants are used by the C<flush> method.
1453
1454 Z_NO_FLUSH
1455 Z_PARTIAL_FLUSH
1456 Z_SYNC_FLUSH
1457 Z_FULL_FLUSH
1458 Z_FINISH
1459 Z_BLOCK
1460
1461=item :level
1462
1463These symbolic constants are used by the C<Level> option in the constructor.
1464
1465 Z_NO_COMPRESSION
1466 Z_BEST_SPEED
1467 Z_BEST_COMPRESSION
1468 Z_DEFAULT_COMPRESSION
1469
1470
1471=item :strategy
1472
1473These symbolic constants are used by the C<Strategy> option in the constructor.
1474
1475 Z_FILTERED
1476 Z_HUFFMAN_ONLY
1477 Z_RLE
1478 Z_FIXED
1479 Z_DEFAULT_STRATEGY
2b4e0969 1480
1481
1482=item :zip_method
1483
1484These symbolic constants are used by the C<Method> option in the
1485constructor.
1486
1487 ZIP_CM_STORE
1488 ZIP_CM_DEFLATE
1489 ZIP_CM_BZIP2
1490
1491
25f0751f 1492
1493
1494=back
1495
1496For
1497
1498=head1 EXAMPLES
1499
1500TODO
1501
1502
1503
1504
1505
1506
e7d45986 1507
1508
1509
1510
1511
25f0751f 1512=head1 SEE ALSO
1513
1514L<Compress::Zlib>, L<IO::Compress::Gzip>, 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::Uncompress::AnyInflate>, L<IO::Uncompress::AnyUncompress>
1515
1516L<Compress::Zlib::FAQ|Compress::Zlib::FAQ>
1517
1518L<File::GlobMapper|File::GlobMapper>, L<Archive::Zip|Archive::Zip>,
1519L<Archive::Tar|Archive::Tar>,
1520L<IO::Zlib|IO::Zlib>
1521
1522
1523For RFC 1950, 1951 and 1952 see
1524F<http://www.faqs.org/rfcs/rfc1950.html>,
1525F<http://www.faqs.org/rfcs/rfc1951.html> and
1526F<http://www.faqs.org/rfcs/rfc1952.html>
1527
1528The I<zlib> compression library was written by Jean-loup Gailly
1529F<gzip@prep.ai.mit.edu> and Mark Adler F<madler@alumni.caltech.edu>.
1530
1531The primary site for the I<zlib> compression library is
1532F<http://www.zlib.org>.
1533
1534The primary site for gzip is F<http://www.gzip.org>.
1535
1536
1537
1538
25f0751f 1539=head1 AUTHOR
1540
cb7abd7f 1541This module was written by Paul Marquess, F<pmqs@cpan.org>.
25f0751f 1542
1543
1544
1545=head1 MODIFICATION HISTORY
1546
1547See the Changes file.
1548
1549=head1 COPYRIGHT AND LICENSE
25f0751f 1550
1551Copyright (c) 2005-2006 Paul Marquess. All rights reserved.
1552
1553This program is free software; you can redistribute it and/or
1554modify it under the same terms as Perl itself.
1555
1556