Hi Joe,

The only point of using mason_globals is to be able to use global  
variables in components without a package qualifier - e.g. $foo.

To refer to such a variable outside components, you either need to  
refer to its full package - $HTML::Mason::Commands::foo - or use  
$interp->set_global.

In practice, over the years, I've found (as you apparently did) that  
is easier to pick a short package name and use that for any globals I  
might have. I find it more readable, too, as it clearly highlights  
which variables are globals.

In Mason 2, each component will be in a separate class, which means  
there will no longer be a way to use unqualified globals. On the plus  
side, you'll be able to declare subroutines local to a component.

HTH,
Jon

On Oct 22, 2009, at 11:40 PM, Joe Pepersack wrote:

> Never mind, I figured it out myself... the answer was staring me in  
> the
> face all night.
>
> If I declare $::FOO it's visible to both the CGI and Mason.  D'oh.
>
> So, with that being the case, what's the point in using the
> mason_globals config parameter?   I'm guessing under mod_perl that  
> would
> let you have a "global" $foo under vhost1 and another "global" $foo in
> vhost... whereas (and, again, I'm guessing) $::FOO would be visible
> across all vhosts.  Is that how it works?
>
>
> ------------------------------------------------------------------------------
> Come build with us! The BlackBerry(R) Developer Conference in SF, CA
> is the only developer event you need to attend this year. Jumpstart  
> your
> developing skills, take BlackBerry mobile applications to market and  
> stay
> ahead of the curve. Join us from November 9 - 12, 2009. Register now!
> http://p.sf.net/sfu/devconference
> _______________________________________________
> Mason-users mailing list
> Mason-users@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/mason-users


------------------------------------------------------------------------------
Come build with us! The BlackBerry(R) Developer Conference in SF, CA
is the only developer event you need to attend this year. Jumpstart your
developing skills, take BlackBerry mobile applications to market and stay 
ahead of the curve. Join us from November 9 - 12, 2009. Register now!
http://p.sf.net/sfu/devconference
_______________________________________________
Mason-users mailing list
Mason-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/mason-users

Reply via email to