Subject: | list_archive() calls $obj->new(); this is not supported |
I have already reported this bug via mail to kane at cpan.org;
no response since Mon Apr 26 2004.
The list_archive method calls new() this way:
sub list_archive {
my $class = shift;
[...]
my $tar = $class->new($file, $gzip);
[...]
}
...which, if list_archive was called as a method on an object,
generates an error:
Attempt to bless into a reference at /usr/share/perl5/vendor_perl/Archive/Tar.pm line 91.
...because new() did "return bless {...}, shift". This problem is shown
by the File::Archive's test suite (version 0.53, test 5).
Attached patch adds support for this case to new().
--- Archive-Tar-1.08/lib/Archive/Tar.pm~ 2004-04-26 15:15:49.041516984 +0200
+++ Archive-Tar-1.08/lib/Archive/Tar.pm 2004-04-26 15:16:22.226472104 +0200
@@ -85,10 +85,12 @@
}
sub new {
+ my $class = shift;
+ $class = ref $class if ref $class;
### copying $tmpl here since a shallow copy makes it use the
### same aref, causing for files to remain in memory always.
- my $obj = bless { _data => [ ], _file => 'Unknown' }, shift;
+ my $obj = bless { _data => [ ], _file => 'Unknown' }, $class;
$obj->read( @_ ) if @_;