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 |