-I'll try to use, in my Perl scripts, lexical variables instead of globalvariables, so that I'm sure the used memory can be resued for later requests (global variables, on the other hand, stick in memory, due to mod perl wayof operating)Not really. In terms of memory, there's no difference. The reason you should use lexicals is that it's a better programming style. There's really no difference in the way globals behave under mod_perl. You just don't notice it under CGI because the process quits right after the request has been served.
Here, I'm getting confused.Let's imagine I'm running the following script though ModPerl::PerlRun or ModPerl::Registry:
use strict; package mypack; my $lexical; our $global; print lexical: ' . $lexical. ' # global: ' . $global; $lexical= 2007; $global = 2007; This script would print: lexical: # global: the first time it is run and then: lexical: # global: 2007So, this clearly shows that the global variables sticks in memory, while the lexical one doesn't. So, I would imagine that after the script is run, space used by the lexical variable would be freed up.
Am I wrong?
Mail converted by mhonarc 2.6.15
This archive provided courtesy of JSW4.NET, Internet Hosting Services for Small Business.