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

I've been playing around with Perl.pm recently, mostly involving efforts to compile a script once and then run it multiple times, for speed purposes. I have finally managed, through much hackery, to get it mostly working. Then he author told me that you must not call perl_run twice on a given interpreter. Does anyone have any idea why? And more importantly, is there a way to fix it, or a better way to do it?

Replies are listed 'Best First'.
Re: perlembed: perl_run twice?
by tachyon (Chancellor) on Oct 25, 2004 at 04:02 UTC

    I expect it is because on most systems, some of the C libraries are not re-entrant; particularly, memory allocation and I/O routines. This sounds like the same issue with signal handlers not being re-entrant covered in perlipc. The problems will likely manifest as core dumps.

    NB: A re-entrant (thread safe) library protects its internal data structures from corruption due to the potential for simultaneous access.

    cheers

    tachyon

Re: perlembed: perl_run twice?
by thospel (Hermit) on Oct 25, 2004 at 10:00 UTC
    Not really answering your question, but wondering if using Perl.pm is the right way to do it considering the problems you have with it.

    The traditional perl way to get the required effect is persistent already interpreted code by using something like SpeedyCGI (which is not CGI only whatever its name may suggest) or PPerl.