Skip to content

Commit 68c9fd0

Browse files
committed
Rewrite iindirect "new" to "->new"
1 parent d3fc968 commit 68c9fd0

File tree

8 files changed

+311
-281
lines changed

8 files changed

+311
-281
lines changed

examples/gz2zip.pl

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
use strict;
2+
use warnings;
3+
4+
use IO::Uncompress::Gunzip qw(gunzip $GunzipError);
5+
use Archive::Zip::SimpleZip qw($SimpleZipError);
6+
7+
die "Usage: gz2zip.pl zipfilename gzfile1 gzfile2...\n"
8+
unless @ARGV >= 2 ;
9+
10+
my $zipFile = shift ;
11+
my $zip = Archive::Zip::SimpleZip->new($zipFile)
12+
or die "Cannot create zip file '$zipFile': $SimpleZipError";
13+
14+
for my $gzFile (@ARGV)
15+
{
16+
my $cleanName = $gzFile ;
17+
$cleanName =~ s/\.gz$//;
18+
19+
print "Adding $cleanName\n" ;
20+
my $zipMember = $zip->openMember(Name => $cleanName)
21+
or die "Cannot openMember file '$cleanName': $SimpleZipError\n" ;
22+
23+
gunzip $gzFile => $zipMember
24+
or die "Cannot gunzip file '$gzFile': $GunzipError $SimpleZipError\n" ;
25+
}

lib/Archive/Zip/SimpleUnzip.pm

Lines changed: 24 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ our %PARAMS = (
3434

3535
sub _ckParams
3636
{
37-
my $got = IO::Compress::Base::Parameters::new();
37+
my $got = IO::Compress::Base::Parameters->new();
3838

3939
$got->parse(\%PARAMS, @_)
4040
or _myDie("Parameter Error: " . $got->getError()) ;
@@ -94,7 +94,7 @@ sub new
9494
return _illegalFilename
9595
}
9696

97-
$fh = new IO::File "<$inValue"
97+
$fh = IO::File->new("<$inValue")
9898
or return _setError(undef, undef, "cannot open file '$inValue': $!");
9999
}
100100
elsif( $inType eq 'buffer' || $inType eq 'handle')
@@ -806,7 +806,7 @@ sub STORABLE_thaw
806806
if ($self->isFile())
807807
{
808808
my $handle = $self->open();
809-
my $fh = new IO::File ">$filename"
809+
my $fh = IO::File->new(">$filename")
810810
or return _setError("Cannot open file '$filename': $!");
811811
#$fh->binmode(); # not available in 5.8.0
812812

@@ -972,7 +972,7 @@ Archive::Zip::SimpleUnzip - Read Zip Archives
972972
973973
use Archive::Zip::SimpleUnzip qw($SimpleUnzipError) ;
974974
975-
my $z = new Archive::Zip::SimpleUnzip "my.zip"
975+
my $z = Archive::Zip::SimpleUnzip->NEW('my.zip')
976976
or die "Cannot open zip file: $SimpleUnzipError\n" ;
977977
978978
# How many members in the archive?
@@ -982,21 +982,21 @@ Archive::Zip::SimpleUnzip - Read Zip Archives
982982
my @names = $z->names();
983983
984984
# Test member existence
985-
if ($z->exists("abc.txt"))
985+
if ($z->exists('abc.txt'))
986986
{
987987
...
988988
}
989989
990990
# Extract member to filesystem
991-
$z->extract("member") ;
992-
$z->extract("member", "outfile") ;
991+
$z->extract('member') ;
992+
$z->extract('member', 'outfile') ;
993993
994994
995995
# Read the zip comment
996996
my $comment = $zip->comment();
997997
998998
# Select a member by name
999-
my $member = $z->member("abc.txt");
999+
my $member = $z->member('abc.txt');
10001000
my $name = $member->name();
10011001
my $content = $member->content();
10021002
my $comment = $member->comment();
@@ -1050,9 +1050,9 @@ Note that the code assume that the zip archive is being read from a seekable fil
10501050
10511051
=head2 Constructor
10521052
1053-
$z = new Archive::Zip::SimpleUnzip "myzipfile.zip" [, OPTIONS] ;
1054-
$z = new Archive::Zip::SimpleUnzip \$buffer [, OPTIONS] ;
1055-
$z = new Archive::Zip::SimpleUnzip $filehandle [, OPTIONS] ;
1053+
$z = Archive::Zip::SimpleUnzip->new('myzipfile.zip' [, OPTIONS]) ;
1054+
$z = Archive::Zip::SimpleUnzip->new(\$buffer [, OPTIONS]) ;
1055+
$z = Archive::Zip::SimpleUnzip->new($filehandle [, OPTIONS]) ;
10561056
10571057
The constructor takes one mandatory parameter along with zero or more
10581058
optional parameters.
@@ -1117,7 +1117,7 @@ If the optional parameter $outfile is specified, the payload is written to that
11171117
11181118
Returns the comment, if any, associated with the zip archive.
11191119
1120-
=item $z->exists("name")
1120+
=item $z->exists('name')
11211121
11221122
Tests for the existence of member "name" in the zip archive.
11231123
@@ -1139,10 +1139,10 @@ Standard usage is
11391139
11401140
use Archive::Zip::SimpleUnzip qw($SimpleUnzipError) ;
11411141
1142-
my $match = "hello";
1143-
my $zipfile = "my.zip";
1142+
my $match = 'hello';
1143+
my $zipfile = 'my.zip';
11441144
1145-
my $z = new Archive::Zip::SimpleUnzip $zipfile
1145+
my $z = Archive::Zip::SimpleUnzip->new($zipfile)
11461146
or die "Cannot open zip file: $SimpleUnzipError\n" ;
11471147
11481148
while (my $member = $z->next())
@@ -1215,10 +1215,10 @@ read the contents of the member
12151215
12161216
use Archive::Zip::SimpleUnzip qw($SimpleUnzipError) ;
12171217
1218-
my $z = new Archive::Zip::SimpleUnzip "my1.zip"
1218+
my $z = Archive::Zip::SimpleUnzip->new('my1.zip')
12191219
or die "Cannot open zip file: $SimpleUnzipError\n" ;
12201220
1221-
my $name = "abc.txt";
1221+
my $name = 'abc.txt';
12221222
if ($z->exists($name))
12231223
{
12241224
print $z->content($name);
@@ -1232,8 +1232,8 @@ read the contents of the member
12321232
12331233
use Archive::Zip::SimpleUnzip qw($SimpleUnzipError) ;
12341234
1235-
my $zipfile = "my.zip";
1236-
my $z = new Archive::Zip::SimpleUnzip $zipfile
1235+
my $zipfile = 'my.zip';
1236+
my $z = Archive::Zip::SimpleUnzip->new($zipfile)
12371237
or die "Cannot open zip file: $SimpleUnzipError\n" ;
12381238
12391239
my $members = $z->names();
@@ -1253,10 +1253,10 @@ constructor to automaticaly skip members that just contain directories.
12531253
12541254
use Archive::Zip::SimpleUnzip qw($SimpleUnzipError) ;
12551255
1256-
my $match = "hello";
1257-
my $zipfile = "my.zip";
1256+
my $match = 'hello';
1257+
my $zipfile = 'my.zip';
12581258
1259-
my $z = new Archive::Zip::SimpleUnzip $zipfile, FilesOnly => 1
1259+
my $z = Archive::Zip::SimpleUnzip->new($zipfile, FilesOnly => 1)
12601260
or die "Cannot open zip file: $SimpleUnzipError\n" ;
12611261
12621262
while (my $member = $z->next())
@@ -1282,10 +1282,10 @@ to get a filehandle for each member of a zip archive which it passes to C<Archi
12821282
my $input = shift ;
12831283
my $output = shift ;
12841284
1285-
my $unzip = new Archive::Zip::SimpleUnzip $input
1285+
my $unzip = Archive::Zip::SimpleUnzip->new($input)
12861286
or die "Cannot open '$input': $SimpleUnzipError";
12871287
1288-
my $zip = new Archive::Zip::SimpleZip $output, Level => Z_BEST_COMPRESSION
1288+
my $zip = Archive::Zip::SimpleZip->new($output, Level => Z_BEST_COMPRESSION)
12891289
or die "Cannot create zip file '$output': $SimpleZipError";
12901290
12911291
while (my $member = $unzip->next())

0 commit comments

Comments
 (0)