Re: "use" etiquette in mod_perl

[prev] [thread] [next] [Date index for 2004/11/14]

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.org
mailto:stas@xxxxxx.xxx 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

"use" etiquette in mod_perl
Mark S Lowe 21:56 on 13 Nov 2004

Re: "use" etiquette in mod_perl
Stas Bekman 03:52 on 14 Nov 2004

Re: "use" etiquette in mod_perl
Stas Bekman 23:11 on 14 Nov 2004

Generated at 11:26 on 21 Dec 2004 by mariachi v0.52