Beefy Boxes and Bandwidth Generously Provided by pair Networks
Syntactic Confectionery Delight
 
PerlMonks  

Perl Modules - Mod_Perl and CGI

by Trihedralguy (Pilgrim)
on Apr 29, 2013 at 00:59 UTC ( #1031135=perlquestion: print w/ replies, xml ) Need Help??
Trihedralguy has asked for the wisdom of the Perl Monks concerning the following question:

For a long time, I've put up with either Mod_Perl or some sort of Apache2::Reload problem. It seems that I cannot get the configuration correct. I seriously need some wisdom.

My problem is that if I change a perl module, I get "Internal Server" errors on the screen and in the error log I get things like:

maybe use strict error: Subroutine new redefined at Item.pm line 13

Refreshing the page a few times and eventually the "cache" clears. Most of the time refreshing very quickly gives me this:

Attempt to reload Item.pm aborted. <--> Compilation failed in require at (eval 109) line 3

I am using Mod_Perl and CGI together -- I've also attempted to use Apache2::Reload which claims to "Fix" this problem. In my httpd.conf file I have these, like the module suggests:

PerlModule Apache2::Reload PerlInitHandler Apache2::Reload

In a development situation I want my perl modules to be checked and recomplied the moment I make a new change, I dont really care about performance when I'm constantly making changes and getting the code layed down.

Anyway -- I hope someone out there has a proper answer for this. I love developing in Perl/CGI, its gotten me some awesome results. But moving to PM files and OO is becoming a struggle when my Perl modules are constantly acting up. Any suggestions are extremely welcome.

Thanks!!

Comment on Perl Modules - Mod_Perl and CGI
Select or Download Code
Re: Perl Modules - Mod_Perl and CGI (question)
by Anonymous Monk on Apr 29, 2013 at 07:44 UTC
      I haven't had the chance to try what you are saying above. My goal is to NOT have to press "refresh" a bunch of times to finally get apache to reload my perl modules.

        My goal is to NOT have to press "refresh" a bunch of times to finally get apache to reload my perl modules.

        A bunch of times? All it takes is once (one request)

Re: Perl Modules - Mod_Perl and CGI
by sundialsvc4 (Monsignor) on Apr 29, 2013 at 15:24 UTC

    mod_perl embeds a Perl interpreter inside an Apache worker-process.   Therefore, if you change the Perl code, you must restart Apache.   Make very sure that the Perl code actually works, in the environment (PERL5LIB, etc...) created by the Apache instance.   It sounds like it’s got some basic syntax errors ...

        What he is saying seems true and is the case when I'm most frustrated. Restarting Apache fixes the problem. What I'm hoping to discover is a solution to turn of the caching on the development machine, so that I can quickly make changes without having to restart or "refresh constantly" to un-cache an error.
      I found this with your words mentioned: http://www.openswartz.com/2009/09/22/how-not-to-restart-mod_perl-servers/

      I wish there was a proper solution.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://1031135]
Approved by ww
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others taking refuge in the Monastery: (15)
As of 2014-07-10 17:59 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    When choosing user names for websites, I prefer to use:








    Results (215 votes), past polls