Beefy Boxes and Bandwidth Generously Provided by pair Networks
Do you know where your variables are?
 
PerlMonks  

Re: Accessing hash from within module

by bart (Canon)
on Feb 12, 2012 at 02:07 UTC ( #953273=note: print w/replies, xml ) Need Help??


in reply to Accessing hash from within module

You might think of importing the variable into your main package, if it is defined in a module.

That's actually do the same thing as Jenda's code snippets, but it looks just a bit less hacky. See Exporter for one way to implement it.

You could also think of declaring the global variables in a dedicated module and use it in any module that requires access to them.

Also note that you can use "::" as short for "main::". So you could just spell it as %::lglobal (and $::lglobal{$key}), which doesn't look to bad to me. You could event think of the "::" prefix as hungarian notation, so it could even work out for the better.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://953273]
help
Chatterbox?
[Corion]: marto: Ow! You got hit by the storm that is bringing warm weather to me ...
[1nickt]: marto Good to hear that was the worst of it for you...
[marto]: 1nickt the worst I'm aware of at the moment :P
LanX .♩..♬ ... Another one bites the Sahara dust ...
marto wonders what fresh hell the firefox update has brought, apart from maxing out CPUs
1nickt was looking into Firefox Extended Support releases yesterday. You don't have to go with the updates!
[erix]: wonderfully red sun here
[LanX]: FF has become a source of instability :(

How do I use this? | Other CB clients
Other Users?
Others cooling their heels in the Monastery: (8)
As of 2017-10-17 12:27 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    My fridge is mostly full of:

















    Results (230 votes). Check out past polls.

    Notices?