[reordered to bottom style posting]
> -----Original Message-----
>
> >From: Shawn Corey <[EMAIL PROTECTED]>
> >Sent: Jan 15, 2006 10:58 PM
> >To: beginners@perl.org
> >Subject: Re: about the var's scope
> >
> >Jeff Pang wrote:
> >> Hello,lists,
> >>
> >> Seeing these code below please.I can't know why the var defined in the
> >> main script can been accessed in the modules that used by the main
> >> script?thanks.
> >
> > From `perldoc vars`:
> >
> >While the vars pragma cannot duplicate the effect of package lexicals
> >(total transparency outside of the package), it can act as an acceptable
> >substitute by pre-declaring global symbols, ensuring their availability
> >to the later-loaded routines.
> >
> >This means any variable declared by vars can be accessed outside of the
> >file it is declared in.
> >
> >The second part of the understanding comes from Exporter. When it
> >exports a thingy, it uses a typeglob to make the thingy in the package
> >the same as in the 'use'ing module. In other words, for your My::HTML
> >module, it does this:
> >
> >   $main::q = \*My::HTML::q;
> >
> >
> >For more details, see:
> >
> >   perldoc vars
> >   perldoc -f our
> >   perldoc perlfunc (and search for 'our')
> >
> >   perldoc Exporter
> >   perldoc perlop (and search for 'typeglob')
> >   perldoc perlsub (and search for 'typeglob')
> >
> >Just my 0.00000002 million dollars worth,
> >    --- Shawn
[...]

Jeff Pang am Montag, 16. Januar 2006 01.59:
> Thanks for Shawn.The main script can see the global var $q coming from
> module,since the main script import this symbol via 'use My::HTML
> qw($q)'.But the modules have no any importing behavior,why they can see the
> global var $q coming from main script?I'm really confused for that.

Ok, it would be interesting to look deeper into the mess of different 
variables all named with the same name $q, exported across the modules, 
overwritten by several imports...

What do you want to achieve with your code? It looks really strange (hm, at 
least to me).

joe

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>


Reply via email to