[ back to toc ]

Perl eval warnings

Date: 2002/05/29 16:50

Q:
My application generates huge amounts of worthless warnings when run with
the -w switch (yes, the warnings are worthless -- I've looked thru them).
However, my program passes user code thru to an eval. If a user
references an undefined variable, the application silently returns null.
This is an error that is EXTREMELY DIFFICULT to detect. I can't flag on a
null return because sometimes that's what the user wants and asks for. I
need to be able to turn ON warnings during the eval, and OFF afterward.
I've tried brackting the eval code with 'diagnostics::enable()' and
'diagnostics::disable()', but that triggers PERL to issue warnings about
the whole program. That's just as bad as no warnings at all since the
user won't be able to make sense of the pages of worthless drivel that
gets emmitted. How can I turn warnings ON and OFF within my program.

*NAME-DELETED* *NAME-DELETED*
A:
You should have

use strict;

at the start of the eval-ed string.

Regards,
Peter
Q:
Pursuant to your recommendation, I've bracketed the code in 'use Strict's.
It sort of works. It certainly does issue error messages about variables
that haven't been declared. However, that isn't really what I need. We
have a (mostly) standard set of variables, so we'll always declare them.
What I really need is to throw a flag when one of those variables is
undefined at the time it's called by the user's eval code -- much like
running with the -w switch; but, as I said earlier, using the -w in the
main program returns pages of warnings. Useless.

I'm thinking that maybe I can prepend the eval string with
diagnostics::enable, and terminate it with diagnostics::disable. I'll try
it. Any thoughts?
A:
By the time you allready knoe these fetures of Perl better than me.
Really, I am not kidding. In this very question you are already more an
expert than me. I can not help you any more. (In this issue. In other
issues I am open accepting questions of course.)

Regards,
Peter

[ back to toc ]