cgraf has asked for the wisdom of the Perl Monks concerning the following question:

If I run the following script from the command line, I get no warnings.

#!/usr/local/bin/perl use strict; use warnings; my $class = undef; eval { $class->isa('MyClass'); };

however, if I execute the script via a web-browser with the script, the following earning goes to the error_log:

Can't call method "isa" on an undefined value at /home/chrisgrafham/ho +spital/cgi-bin/testEval.pl line 13.

I can not suppress the error log, even when turing warnings off (no warnings;)

Can't call method "isa" on an undefined value at /home/fred/..../cgi-b +in/testEval.pl line 13

Any ideas?

Edit: g0n - code tags and formatting

Replies are listed 'Best First'.
Re: no warnings no working while running cgi script under Apache::Registry
by shmem (Chancellor) on Nov 02, 2007 at 16:40 UTC
    It's not a warning, it's an error, to which $@ is set (see perlvar) by eval; $@ seems to be handled by the caller of your code snippet and thrown out STDERR. You get the same error via the command line, if you check for $@ after eval:
    qwurx [shmem] ~ > perl use strict; use warnings; my $class = undef; eval { $class->isa('MyClass'); }; warn $@ if $@; __END__ Can't call method "isa" on an undefined value at - line 6.

    If you want to supress that error, handle $@ yourself after the eval and set it to the empty string ('') after that.

    Please wrap any piece of code you post into <code> tags. See Writeup Formatting Tips.

    --shmem

    _($_=" "x(1<<5)."?\n".q·/)Oo.  G°\        /
                                  /\_¯/(q    /
    ----------------------------  \__(m.====·.(_("always off the crowd"))."·
    ");sub _{s./.($e="'Itrs `mnsgdq Gdbj O`qkdq")=~y/"-y/#-z/;$e.e && print}