Beefy Boxes and Bandwidth Generously Provided by pair Networks
Pathologically Eclectic Rubbish Lister
 
PerlMonks  

Re: Can you create *real* global variables?

by lepre (Initiate)
on Mar 11, 2007 at 13:40 UTC ( [id://604225]=note: print w/replies, xml ) Need Help??


in reply to Can you create *real* global variables?

This node falls below the community's threshold of quality. You may see it by logging in.

Replies are listed 'Best First'.
Re^2: Can you create *real* global variables?
by Anno (Deacon) on Mar 11, 2007 at 16:45 UTC
    Please put <code>...</code> 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

      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
Domain Nodelet?
Node Status?
node history
Node Type: note [id://604225]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others making s'mores by the fire in the courtyard of the Monastery: (2)
As of 2026-05-10 03:04 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found

    Notices?
    hippoepoptai's answer Re: how do I set a cookie and redirect was blessed by hippo!
    erzuuliAnonymous Monks are no longer allowed to use Super Search, due to an excessive use of this resource by robots.