Re: Other Globals in %once

Dave Rolsky <[email protected]>
Newsgroups gmane.comp.web.mason.devel
Message-ID <[email protected]>
On Wed, 28 Apr 2004, David Wheeler wrote:

> The upshot is that some globals we're setting for the Bricolage Mason
> burner aren't appearing in %once blocks. This is (somewhat) expected,
> but it's odd that Serge only gets an error periodically. Note that
> we're using the "in_package" parameter.
>
> Also, I was wondering what's the reason for not allowing $m and other
> globals?  I'm thinking about setting these globals myself before
> calling $interp->exec(). That way, they should always be there, yes?
> It's not as clean as using $interp->set_global(), but would eliminate
> the complaints. Are there any issues with doing this?

The reason the error appears intermittently has to do with the way Perl
works when run persistently.  The first time it sees an unqualified global
under 'use strict', it throws an error.  However, for some reason, when it
sees the same global again on a later request, it doesn't throw an error.
I think some bit of state of the interpreter is being twiddled, or
something like that.

The upshot is that under mod_perl, you often see "unqualified global"
errors disappear after repeated requests.

The reason for not allowing these globals is that the <%once> block is
only run once ;)

So if a once block included this:

  my $m = HTML::Mason::Request->instance;

then this $m will stay in scope for a long, long time.  That would be bad.


-dave

/*=======================
House Absolute Consulting
www.houseabsolute.com
=======================*/


-------------------------------------------------------
This SF.Net email is sponsored by: Oracle 10g
Get certified on the hottest thing ever to hit the market... Oracle 10g. 
Take an Oracle 10g class now, and we'll give you the exam FREE. 
http://ads.osdn.com/?ad_id=3149&alloc_id=8166&op=click
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.