Subject: | Archive::Tar->new($file) doesn't return undef on failure |
I'm using something like:
$tar = Archive::Tar->new($file);
die unless defined $tar;
print "$tar\n";
on a file with permissions `--w-------'. I get this output:
Could not create filehandle for 'install.tar': Permission denied! at ./install.pl line 111
Archive::Tar=HASH(0x101025d0)
The warning is good, but it should die on the next line. The print command shows that $tar isn't undef, but a hash reference. This is a critical bug for my script, because I add files and write the tar file back to disk. The orginal contents of the tar file are lost.
It looks to me that simply checking what the read method returns and passing undef rather than $obj would do the trick. As an aside, I would welcome a feature simular to DBI's RaiseError, which causes failures to die rather than warn.
Thanks,
Jon Ericson
This is using Archive-Tar-1.08.tar.gz from CPAN. System information follows:
$ perl -v
This is perl, v5.8.4 built for cygwin
Copyright 1987-2004, Larry Wall
Perl may be copied only under the terms of either the Artistic License or the
GNU General Public License, which may be found in the Perl 5 source kit.
Complete documentation for Perl, including FAQ lists, should be found on
this system using `man perl' or `perldoc perl'. If you have access to the
Internet, point your browser at http://www.perl.com/, the Perl Home Page.
$ uname -a
CYGWIN_NT-5.0 Jon-Ericson 1.5.9(0.112/4/2) 2004-03-18 23:05 i686 unknown unknown Cygwin