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: 23:11 on 14 Nov 2004
[ Mark, please don't forget to CC the list ]

Mark S Lowe wrote:
> Out of these two examples, the latter is the better for performance reasons
> right?

As I've written in the original reply, they are exactly the same.

 >>sub foo {
 >>   use Bar;
 >>}
 >>
 >>is the same as:
 >>
 >>use Bar;
 >>sub foo {}

The latter is more idiomatic and readable, precisely because many people 
aren't aware that use is a compile time directive, and it doesn't matter 
where you put it.

> I was trying to decouple my methods as much as possible from outside
> requires or use statements.

You would benefit a lot by spending some time reading the performance+perl 
docs at perl.apache.org:
http://perl.apache.org/docs/1.0/guide/performance.html
http://perl.apache.org/docs/general/perl_reference/perl_reference.html
and if you have the "practical mod_perl" book, the performance chapters there.

in the particular case of your question, most likely you want to preload 
all the modules that your code is using at the server startup.
http://perl.apache.org/docs/1.0/guide/performance.html#Sharing_Memory

        -- 
        __________________________________________________________________
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