Beefy Boxes and Bandwidth Generously Provided by pair Networks
Problems? Is your data what you think it is?

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?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://953273]
[james28909]: how can i write a while loop on one line (in a script) something like print "this\n" && print "that" && <DATA> && print the other\n" && next if /this matches/ while <DATA>?
[james28909]: i have tried with && and and and have tried to rearrange the functions as well to no avail
[shmem]: use parens to group expressions
[shmem]: you can't use next in a statement modifier
[shmem]: next requires a BLOCK

How do I use this? | Other CB clients
Other Users?
Others browsing the Monastery: (6)
As of 2018-05-20 18:44 GMT
Find Nodes?
    Voting Booth?