Hello List,
I am using a module that does use Carp; and you can specify whther you want croak or carp on an error Which is cool. But there is no way to specify anythign else besides those two.
So the way it is you just do:
my $res = funktion('foobarmonkey',err_doer => 'carp');
And it will do carp('what the heck is foobarmonkey');
What I'd like to do is get any errors into a variable:
my $err = ''; my $res = funktion('foobarmonkey',err_doer => 'puterrorinvar');
if($err) {
print "Error: $err\n";
print "Logging error..."'
if(logerror($err) { print "Ok\n"; } else { print "Failed!\n"; }
print "Emailing Admin...";
if(emailadmin($err)) { print "Ok\n"; } else { print "Failed!\n"; }
# and now that we did that we can go ahead and carp, craok die, whatever
}
Except I can't simply specify a new function for errors because it checks for what you enter to see if its in a hash and if not defaults to one or the other. (I could modify the module but then it won't work for all)
SO I guess the question is, is there a way to get carp or croak into a variable?
Something like this perhaps: ?
Maybe. Check out this one liner:
perl -MCarp -e '$SIG{__WARN__} = sub { $err = shift; }; carp "Error!\n"; print "We caught $err";'
Strangely though, this did not work for me, though I expected it to:
perl -MCarp -e '$SIG{__DIE__} = sub { $err = shift; }; croak "Error!\n"; print "We caught $err";'
James
-- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] <http://learn.perl.org/> <http://learn.perl.org/first-response>