I pretty much knew where the problem was and what causes it initially. The program works as expected as long as there is a tar archive as file #1 on the tape. The problem is that I have to make sure that the tape in the drive is the correct one. So I need error handling graceful enough so that the program doesn't generate cron mailings every time it runs.
As you suggest, I can turn off the Archive::Tar warnings and don't need to use $tar->error since $! returns 'I/O error' and will probably serve for most of the other errors I might encounter. Rewritten as follows should meet my needs for now:
use strict; use warnings; use Archive::Tar; $Archive::Tar::WARN = 0; my $device = '/dev/rmt/1'; my $tar = Archive::Tar->new(); $! = 0; $tar->read($device); die "### ERROR on \$tar->read($device): $!\n\n" if $!;
I'll test this further and post my findings if I have to modify the approach further. Thanks for the suggestions, they were very helpful. I'm still very disppointed with the error handling capabilities of this module.
In reply to Re: Re: Archive::Tar and error handling
by Anonymous Monk
in thread Archive::Tar and error handling
by Anonymous Monk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |