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

Can't get this module to run under mod_perl. I have installed this module on my machine and the script when called from command line works fine. But When called from within Apache from a mod_perl script, it fails to instantiate Parse::RecDescent Module. I wrapped the 'Parse::RecDescent->new($grammar)' call in 'eval' and printed out '$@' after in a file. Here is the error : Unknown starting rule (Parse::RecDescent::0::Replace) called at EXPR_EVAL.pm line 20. Again, the same module (EXPR-EVAL.pm) runs just fine when called from a script on the command line! Any suggestions are welcome.
  • Comment on Running Parse::RecDescent Under mod_perl

Replies are listed 'Best First'.
Re: Running Parse::RecDescent Under mod_perl
by alien_life_form (Pilgrim) on May 22, 2002 at 16:31 UTC
    Greetings,

    I do not know what mod_perl experience you are starting from (and you are not saying how are you running it: Apache::Registry, I presume?).

    Startup can be tricky, however. So I suggest you look in the mod_perl guide (if you have not done it already) to get useful suggestions on pitfalls, debugging etc.

    Shooting in the dark (and assuming Apache::Registry) you may bhe falling prey of the "embedded subroutine" trap. If so ypu can easily find out by turning warnings on and looking in your error log: can you see complaints about variables that "will not stay shared" ?
    Cheers,
    alf


    You can't have everything: where would you put it?
Re: Running Parse::RecDescent Under mod_perl
by Juerd (Abbot) on May 22, 2002 at 16:24 UTC

    ...called at EXPR_EVAL.pm line 20.

    What is that line?

    - Yes, I reinvent wheels.
    - Spam: Visit eurotraQ.
    

      That's the line I create RecDescent module object : my $p=Parse::RecDescent->new($grammar) It the goes inside RecDescent.pm file - running 'sub new' and fails towards the end where it tries to call '$self->Replace' . I can see the 'Replace' subroutine a few lines below! Why can't it find the subroutine in the same file and same package? It found 'sub new' for the module successfully!!!
Re: Running Parse::RecDescent Under mod_perl
by perrin (Chancellor) on May 22, 2002 at 16:41 UTC
    It's probably something about the environment being different. Remember, when running under mod_perl the user, path, and environment variables are different from your command-line test. I'd start by looking for possible file permissions problems.