Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl-Sensitive Sunglasses
 
PerlMonks  

Re^2: Can you create *real* global variables?

by Anno (Deacon)
on Mar 11, 2007 at 16:45 UTC ( #604239=note: print w/replies, xml ) Need Help??


in reply to Re: Can you create *real* global variables?
in thread Can you create *real* global variables?

Please put <c>...</c> tags around code.

What's to solve? Are you asking why the package variables $main::V1 and $main::V2 aren't defined when foo::fetchvar() is called?

That's because they were never set. Instead, you set the lexical variables (of file scope) $V1 and $V2.

Change the my declarations for $V1 and $V2 to our and your code will do what (I suppose) you expect it to do.

Anno

Replies are listed 'Best First'.
Re^3: Can you create *real* global variables?
by lepre (Initiate) on Mar 16, 2007 at 18:18 UTC
    The "our" declaration is not documented in the second edition of Wall's book (1996). Oh, gosh, it is 10 years old... Time passes by. Thanks.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://604239]
help
Chatterbox?
choroba needs some CH3CH2OH
[GotToBTru]: 99% of all deaths take place within 24 hours of ingesting di-hydrogen monoxide

How do I use this? | Other CB clients
Other Users?
Others perusing the Monastery: (6)
As of 2016-12-06 12:54 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    On a regular basis, I'm most likely to spy upon:













    Results (104 votes). Check out past polls.