SPUG: Scope question
dancerboy
dancerboy at strangelight.com
Tue Jun 11 19:57:04 CDT 2002
<geriatric coder pontification>
Yes, you should consider this an opportunity to rethink your coding
style and perhaps learn better coding techniques. As any experienced
programmer should be able to tell you, global variable are a Bad
Thing. Many languages (e.g. Java) don't even have globals.
Your modules really ought to be entirely self-contained: any
information that the modules need you should be passed in
*explicitly*. With the exception of language extensions/pragmas, a
module should *never* need to peek into a client's namespace in order
to do its thing.
</geriatric coder pontification>
-jason
At 4:39 pm -0700 2002-06-11, Parr, Ryan wrote:
>Peter,
>
>If you fully qualify the var then it is available. But this isn't any
>different from my understanding of standard module scope. Be careful when
>using global vars from mod_perl though, since the variables will not be
>reset when the request is complete. Also, if you modify the values of your
>global vars at runtime then all of your httpd children will end up with
>different values, which can really bite you. With mod_perl I've found it's
>best to just always use 'my'.
>
>But if you really want to share globals check out
>http://theoryx5.uwinnipeg.ca/cgi-bin/guide-filter?page=perl/Using_Global_Var
>iables_and_Shari.html;query=global;match=and;where=all;stem=no.
>
>-- Ryan Parr
>
>Common sense is the collection of prejudices acquired by age eighteen.
> -- Albert Einstein
>
>
>-----Original Message-----
>From: Peter Darley [mailto:pdarley at kinesis-cem.com]
>Sent: Tuesday, June 11, 2002 3:00 PM
>To: SPUG
>Subject: SPUG: Scope question
>
>
>Friends,
> I have a scope question. I'm using mod_perl with apache, and it
>seems like in my main script (the one that the URL points to) when I do 'use
>vars qw($Thing1 %Thing2)' $Thing1 and %Thing2 are not available to functions
>in modules called from the main script. Is this just an illusion and I have
>some other problem, or is this the way things work? If so, is there some
>way I can share a variable with modules being used by a script? Thanks,
>Peter Darley
>
>
> - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
> 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 daily traffic, use spug-list for LIST ; for weekly, spug-list-digest
> Seattle Perl Users Group (SPUG) Home Page: http://seattleperl.org
>
> - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
> 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 daily traffic, use spug-list for LIST ; for weekly, spug-list-digest
> Seattle Perl Users Group (SPUG) Home Page: http://seattleperl.org
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
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 daily traffic, use spug-list for LIST ; for weekly, spug-list-digest
Seattle Perl Users Group (SPUG) Home Page: http://seattleperl.org
More information about the spug-list
mailing list