You misunderstand the return value of read
of Archive::Tar
:
$tar->read ( $filename|$handle, [$compressed, {opt => 'val'}] )
Returns the number of files read in scalar context, and a list of
Archive::Tar::File
objects in list context.
Please change the following
if(my $error = $tar->read($file)) {
die "Can't read $file : $!";
}
to
unless ($tar->read($file)) {
die "Can't read $file : $!";
}
and try again.