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

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.