Forum Moderators: coopster & phranque

Message Too Old, No Replies

How often are Perl scripts compiled?

Does the Perl compiler maintain a program cache?

         

kaled

11:21 am on Jun 14, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Perl scripts are, I believe, compiled into an intermediate code that is then interpreted.

It seems daft to recompile the program every time it is run so does Perl keep a cache of compiled programs and check the file date (or whatever) to compile the script only when it has been updated?

Kaled.

SeanW

1:11 pm on Jun 14, 2004 (gmt 0)

10+ Year Member



No... It interprets the script every run.

That said, there are some things you can do to fix it. For example, mod_perl handlers keep the perl interpreter and program resident in memory so that it's already parsed and ready to run. Other modules like template toolkit can cache the compiled templates to disk/database to speed that part up, too.

The big overhead is the initial fork of the interpreter. The Perl interpreter is fairly efficient at parsing code, I believe it interprets the script into an intermediate P-code as it runs so that it only chews on what it needs to, and if it needs it again, it's already in p-code format.

Sean