Beefy Boxes and Bandwidth Generously Provided by pair Networks
more useful options
 
PerlMonks  

Good place to learn Apache::PerlRun

by ajt (Prior)
on Sep 21, 2001 at 17:04 UTC ( [id://113868]=perlquestion: print w/replies, xml ) Need Help??

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

I recently got mod_Perl running on my NT/4.0 Apache/1.3.20 Perl/5.6.1 box.

I ported some script from CGI to Apache::PerlRun format and some seem to run okay. Others doing similar things and using similar modules do not.

I will convert them gradually over to full Apache::Registry, but this will take some careful redesign, and time.

In an ideal world I wouldn't use PerlRun, but I have to in the short term. The problems I've seen are caching of values, $ENV in particular isn't being cleaned out. I always use strict and mostly -w, but I'm still getting strange results.

Where do I start? Most of the docs talk about the Registry, PerlRun isn't talked about as much.

Many thanks in advance.

Replies are listed 'Best First'.
(jeffa) Re: Good place to learn Apache::PerlRun
by jeffa (Bishop) on Sep 21, 2001 at 19:26 UTC
    Be sure and get a copy of the mod_perl bible, Writing Apache Modules with Perl and C. On page 45, the gurus talk about Apache::PerlRun very briefly:
      Apache::PerlRun avoids the overhead of launching the Perl interpreter for each request but still suffers the compile-time hit from loading each script.
    Registry and PerlRun are primarly used for lengthy CGI scripts that already work, and you don't have the time to do it 'the right way', where the right way, IMHO, is to write a handler instead.

    So tips since you are stuck in the short term:

    • don't use global variables, especially if you have two or more scripts that use variables with the same names
    • use strict!! (i see you got that covered - awesome)
    • clean up after yourself, close filehandles and database connections
    • buy that book!
    • feel free to post code examples here when the time comes
    and good luck! :)

    jeffa

      Ta

      Many thanks. The book is on order. I've known about it, but assumed it was too Unix or c oriented. However I saw some reviews of it recently complaining that it was too Perl. I thought if it's mostly Perl then it's worth having.

      The PerlRun comments have proved useful. The code that worked okay had no globals, and ran okay first time. The code that was odd, had variables like the environment that wasn't getting cleared - I've mostly fixed that.

      I was caught off guard with __DATA__ as I do use it to store settings in. It doesn't say you can't use that in PerlRun, but if it's really just like Registry then that explains why that doesn't work.

      All I have to do now is find out why LWP::UserAgent isn't working properly, and persuade my home system to run mod_Perl.

      This is a side comment, but I've noticed that Apache on NT can refuse to run some modules. I've installed Apache from the same install file on several NT/2K systems and on some PHP refuses to run, on others it's mod_Perl. My home system runs PHP but not mod_Perl, but my work system runs both!

      Before you tell me to use *nix, I've built Apache/mod_Perl on Linux from scratch with no problems, I just have to use NT for some applications....

      As ever, many thanks!

        NT support is not the greatest in the current version of mod_perl. The upcoming Apache 2/mod_perl 2 will be much better in this regard. For now, you may want to use a pre-compiled binary on NT to make your life easier.
Re: Good place to learn Apache::PerlRun
by perrin (Chancellor) on Sep 21, 2001 at 18:52 UTC
    There are two places to learn about PerlRun: the mod_perl Guide and the mod_perl mailing list. If you ask a specific question on the list, you will usually get a useful answer, but read the Guide first if you want to avoid RTFM answers.

    There's not that much difference between PerlRun and Registry. PerlRun attempts to clear out all globals and subroutines created without an explicit package in your script. Otherwise, it is isn't much different. It sounds like your main questions are general mod_perl issues, and not PerlRun-specific at all. So, ask away!

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others having a coffee break in the Monastery: (5)
As of 2024-04-25 06:58 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found