but I can't figure out how to redirect the carp output

Carp provides a routine shortmess, which just returns the string that carp would write to STDERR.  So you could say

my $error; opendir(DIR, $dir) or $error = Carp::shortmess("Could not open $dir"); mail($error) and die $error if $error;

I have no idea, though, why shortmess is no longer documented in 5.10.x (in 5.8.8 it was), despite the fact that it's still there and works...

Actually, the implementation of carp is just sub carp { warn shortmess @_ }. And shortmess is also in @EXPORT_OK.

P.S.:  Does anyone know if it has been deprecated (nothing related is mentioned in either the 5.10 or the 5.8 docs), or what else might be wrong with using it?


In reply to Re: Improving the Error Handling of my Scripts by almut
in thread Improving the Error Handling of my Scripts by Dru

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.