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

I'm writing a CGI::Application that runs under Apache::Registry and as a regular CGI script. Running just as a CGI, everything works fine, no warnings, no issues with strict, etc. However, when all I do is turn on Apache::Registry handling, I get the following in the error_log:
null: substr outside of string at (eval 234) line 1. null: Use of uninitialized value in pattern match (m//) at (eval 234) +line 1.
Is there any way to get more verbose error reporting than this? I've got four or five modules, and in the one I where I think the error is occuring, line 234 is blank. I've also tried $string ||= "not null anymore" before all of my pattern matching, but to no avail. Any ideas?

Replies are listed 'Best First'.
Re: Tracking down an error in a mod_perl script
by cees (Curate) on May 11, 2003 at 20:35 UTC

    Have a look at the mod_perl_traps perldoc file that is included with mod_perl. There are some hints at what might be going on here. From the docs:

    "Use of uninitialized value" Because of eval context, you may see warnings with useless +filename/line, example: Use of uninitialized value at (eval 80) line 12. Use of uninitialized value at (eval 80) line 43. Use of uninitialized value at (eval 80) line 44. To track down where this eval is really happening, try usin +g a __WARN__ handler to give you a stack trace: use Carp (); local $SIG{__WARN__} = \&Carp::cluck;

    It is surprising that Apache::Registry is having issues with eval'ing your CGI script though, since with CGI::Application your script is so minimal... Do you have anything more complex than the following in your cgi script:

    use WebApp; my $webapp = WebApp->new(); $webapp->run();

    Or are you doing your own eval'ing in your modules?

      That did it. Thanks. :-)

      The problem was coming from Data::FormValidator; I had untaint_all_constraints => 1 set, and when there was nothing that matched (user submits 'a' and the regex is /^\d+$/, for example), Data::FormValidator was throwing out those warnings.
Re: Tracking down an error in a mod_perl script
by hardburn (Abbot) on May 11, 2003 at 20:13 UTC

    You could try use diagnostics, but this is appears to be specific to mod_perl, and diagnostics is only good for perl's internal errors.

    Did you have Apache reload your modules after you changed them? Under mod_perl, it won't do it on its own.

    ----
    I wanted to explore how Perl's closures can be manipulated, and ended up creating an object system by accident.
    -- Schemer

    Note: All code is untested, unless otherwise stated

      use diagnostics; gave me more information about what the error messages mean, but not where they're occurring.

      As far as the modules go, I have it running under Apache::Reload, but I also restarted it a few times for good measure. :-)