Beefy Boxes and Bandwidth Generously Provided by pair Networks vroom
No such thing as a small change
 
PerlMonks  

Re: Can Perl remain persistent for scripts just like mod_perl does for apache?

by ichimunki (Priest)
on Dec 30, 2000 at 00:30 UTC ( [id://48948]=note: print w/replies, xml ) Need Help??

This is an archived low-energy page for bots and other anonmyous visitors. Please sign up if you are a human and want to interact.


in reply to Can Perl remain persistent for scripts just like mod_perl does for apache?

What would be the advantage to this? The interpretation of the script is the slow part of start-up, if I'm not mistaken.

If you want your script to stay in memory run the whole thing from inside a while (1) loop, with an explicit option to exit somewhere inside the loop.
  • Comment on Re: Can Perl remain persistent for scripts just like mod_perl does for apache?

Replies are listed 'Best First'.
Re: Answer: Can Perl remain persistent for scripts just like mod_perl does for apache?
by Anonymous Monk on Dec 30, 2000 at 02:03 UTC
    The /usr/bin/perl executable can take a second to start itself before it even begins to look at the script. That time would be saved.
    Also, mod_perl will keep the compiled version of the script in memory so that it doesn't need to be interpreted before running again. If you were to have a large script several thousand lines long, this would save time. Lastly, since perl is used so much, any time saved each time is lots of time saved overall!
      If you're worried about performance this bad, consider turning your script into a daemon of sorts, either listening on a network socket, a unix domain socket or a fifo of some kind.
      1) The only time the executable is not already in memory is when you type "perl script.pl". If I do a perl -e 'print "Hello World\n";' from my CLI it responds in an eyeblink. This leads me to believe that the only serious overhead concerns are related to interpretation... hence my suggestion that

      2) You can keep a script in memory by using a while loop, or you can set up a controller script that uses the other scripts you want precompiled and starts one of them up on command.

      3) Check the FAQ for more information on compiling scripts and reducing the size of your perl executable.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://48948]
help
Sections?
Information?
Find Nodes?
Leftovers?
    Notices?
    hippoepoptai's answer Re: how do I set a cookie and redirect was blessed by hippo!
    erzuuliAnonymous Monks are no longer allowed to use Super Search, due to an excessive use of this resource by robots.