[ back to toc ]

Perl eval warnings

Date: 2002/05/23 11:28

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.

You should have

use strict;

at the start of the eval-ed string.


[ back to toc ]