John,
These codes are written by famous mod_perl expert Stas Berkman,do you know it?
You can find them at:
http://www.perl.com/pub/a/2002/04/23/mod_perl.html?page=1

maybe you don't know them,but it don't mean that it is impossible.Hm...

-----Original Message-----
>From: John Doe <[EMAIL PROTECTED]>
>Sent: Jan 16, 2006 9:48 AM
>To: beginners@perl.org
>Subject: Re: about the var's scope
>
>[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>
>
>


--
http://home.earthlink.net/~pangj/

-- 
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