From: Stas Bekman Subject: Re: "use" etiquette in mod_perl Date: 03:52 on 14 Nov 2004
Mark S Lowe wrote:
> Quick performance question: Will it kill performance to make sub routines in> mod_perl call all their own use statements? For instance, I have several sub> routines that need to query $q->param(foo), and Iım curious if I should> create a single instance of $q and pass it into all the respective sub> routines, or if itıs okay to have each method create their own $q = new CGI;> instance.
You certainly want to create it once per request and pass it around. Or if
you are careful use a global instance (or singleton)
Though I don't understand what do you mean by 'use'
sub foo {
use Bar;
}
is the same as:
use Bar;
sub foo {}
if that's what you mean. Since use a compile time directive. You want to
use require() to do that at run-time.
--
__________________________________________________________________
Stas Bekman JAm_pH ------> Just Another mod_perl Hacker
http://stason.org/ mod_perl Guide ---> http://perl.apache.orgmailto:stas@xxxxxx.xxxhttp://use.perl.orghttp://apacheweek.comhttp://modperlbook.orghttp://apache.orghttp://ticketmaster.com
--
Report problems: http://perl.apache.org/bugs/
Mail list info: http://perl.apache.org/maillist/modperl.html
List etiquette: http://perl.apache.org/maillist/email-etiquette.html