in reply to Improving the Error Handling of my Scripts

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?

Replies are listed 'Best First'.
Re^2: Improving the Error Handling of my Scripts [OT: Carp shortmess]
by toolic (Bishop) on Mar 11, 2010 at 14:37 UTC
    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... 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?
    I do not know of anything wrong with shortmess. A quick glance at delta docs does not reveal anything. I recommend you submit a patch to add this back into the POD using perlbug. Either it will be fixed, or you should get a response explaining why it will not be fixed.

    I have been planning to submit a patch for a minor POD bug in Carp, but I have been too Lazy.