You are viewing a plain text version of this content. The canonical link for it is here.
Posted to modperl@perl.apache.org by Mark S Lowe <ms...@twin-monolith.com> on 2004/11/13 22:56:07 UTC

"use" etiquette in mod_perl

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. 

Just checking. Thanks!

Mark

Re: "use" etiquette in mod_perl

Posted by Stas Bekman <st...@stason.org>.
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.org
mailto:stas@stason.org http://use.perl.org http://apacheweek.com
http://modperlbook.org http://apache.org   http://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