"be consistent" | |
PerlMonks |
Tying events to perl warnings and errorsby jcwren (Prior) |
on Sep 13, 2000 at 22:53 UTC ( [id://32319]=perlquestion: print w/replies, xml ) | Need Help?? |
jcwren has asked for the wisdom of the Perl Monks concerning the following question:
Is there any way to trigger a piece of code on a warning generated by -w? I have a piece of code that gets run intermittently, and every so often, it gets a warning about an uninitialized variable. Now, I could put some code that tests the variable that I *suspect* is bad before usage (this is a multiple hash dereference), but I don't know that I'd catch it, and I'd have to wait for the program to run again. What I'd rather do is setup a code trap that would record the states of those variable in the subroutine, and a few others, using Data::Dumper or somesuch, to a file. Consider the following fragment of code. We know that 3 parameters are being passed, since the @_ == 3 test passes, but without wrapping a test around each parameter, the perl diagnostics don't tell us *which* variable is the cause for the error messages. Anyone got any good ideas on this? Besides using tie() to every variable I might possibly reference... And why the perl interpeter couldn't print *what* variable is uninitialized? --Chris
Back to
Seekers of Perl Wisdom
|
|