andy at n2h2.com
Mon Jul 10 18:03:08 CDT 2000
On Jul 10, 2000 @ 3:37pm, Jonathan Gardner wrote:
> We're using mod_perl on apache and we want to improve the performance and
> ease of programming our scripts. One of the ideas was centralizing important
> urls in their appropriate modules. The problem is that having a module run
> on several scripts, the chance of having a script actually change a variable
> in that module is good, and since the modules are persistent, the change
> would remain after the script finished. So we need some way of protecting
> our variables from being changed, while keeping them easy to access.
I'm assuming you're using mod_perl via Apache::Registry and not writing
actual mod_perl Perl handlers.
Are you using global (package) variables? Shouldn't be. That gets rid of
that problem. If you have file bound lexicals in the module (or lexicals
bound to a closure), then you'll want to establish an initialization
procedure for those scripts using the module (have &TheModule::import()
perform the initialization for you for extra laziness).
> If this were C++ (and it isn't) I would define those variables as const. The
Thank all that is good in the world (and Larry Wall)!
> perl constant pragma (or is it a module? I am not sure...) works but it is
> clunky to use. You can't use those constants as regular variables, unless
> you jimmy them around.
Perl's 'use constant pragma (which is a module) uses named subroutines as
the constants. They become "inlined" if it's obvious to perl that the
return value is indeed a constant.
> My idea was to build a module called something like:
Bleh. Too complicated.
Andrew Sweger <andy at n2h2.com> | N2H2, Incorporated
Systems Architect | 900 Fourth Avenue, Suite 3400
Advanced Technologies Division | Seattle WA 98164-1059
v=206.336.2947 f=206.336.1541 | http://www.n2h2.com/
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
POST TO: spug-list at pm.org PROBLEMS: owner-spug-list at pm.org
Subscriptions; Email to majordomo at pm.org: ACTION LIST EMAIL
Replace ACTION by subscribe or unsubscribe, EMAIL by your Email-address
For full traffic, use spug-list for LIST ; otherwise use spug-list-digest
Seattle Perl Users Group (SPUG) Home Page: http://www.halcyon.com/spug/
More information about the spug-list