H
Hal Vaughan
I have several Perl daemons running on a particular system. For the most
part, they are behaving well, but I notice that two need to be restarted a
few times a week. I have a lot of logging statements saying what the
program is doing at different points. What I'd like to do is log the
actual errors before the program dies (and is then restarted by it's
monitor). In the routine, I want to be able to print the line number and
type of error (as given in the normal error messages) to my log file.
Is there any way, inside a Perl module, to do something like "If there are
any errors, don't die, call this function, THEN die"? (Or just "call this
function" and I can always make the function itself terminate the program.)
I know the FAQ mentions using eval, but they reference Larry Wall's
"&realcode", which, when I Google it, comes up with references to the same
FAQ, where it is not explained. I'm trying to understand using eval, but I
don't see how I could put an entire module in an eval block -- I would
expect that to only evaluate it when the module is loaded. The few
examples of this (that I can find) are, at least to me, hard to follow, so
clearer examples would help a LOT. (I'm wondering if, since it's in the
FAQ, nobody's bothered to cover this in depth or with more examples.)
For example, if most of what the program does is in the module, how would I
use eval around the subroutine calls from the main program? Can I get away
with having one call to the mainloop (which is in a subroutine by itself)
in it and then using eval only around that one call to the main loop?
Any help in clarifying this is appreciated!
Hal
part, they are behaving well, but I notice that two need to be restarted a
few times a week. I have a lot of logging statements saying what the
program is doing at different points. What I'd like to do is log the
actual errors before the program dies (and is then restarted by it's
monitor). In the routine, I want to be able to print the line number and
type of error (as given in the normal error messages) to my log file.
Is there any way, inside a Perl module, to do something like "If there are
any errors, don't die, call this function, THEN die"? (Or just "call this
function" and I can always make the function itself terminate the program.)
I know the FAQ mentions using eval, but they reference Larry Wall's
"&realcode", which, when I Google it, comes up with references to the same
FAQ, where it is not explained. I'm trying to understand using eval, but I
don't see how I could put an entire module in an eval block -- I would
expect that to only evaluate it when the module is loaded. The few
examples of this (that I can find) are, at least to me, hard to follow, so
clearer examples would help a LOT. (I'm wondering if, since it's in the
FAQ, nobody's bothered to cover this in depth or with more examples.)
For example, if most of what the program does is in the module, how would I
use eval around the subroutine calls from the main program? Can I get away
with having one call to the mainloop (which is in a subroutine by itself)
in it and then using eval only around that one call to the main loop?
Any help in clarifying this is appreciated!
Hal