Beefy Boxes and Bandwidth Generously Provided by pair Networks
Just another Perl shrine

Re: How to access main package global vars in modules

by philipbailey (Chaplain)
on Jul 07, 2011 at 19:20 UTC ( #913246=note: print w/replies, xml ) Need Help??

in reply to How to access main package global vars in modules

There are several alternative one line changes that do what you ask, such as:

  • Declare $glbA and $glbB with our in
  • Refer to those variables in with the fully qualified $main::glbA and $main::glbB
  • no strict "vars"

But none of the above is recommended. You would be much better in most scenarios to make a package, and pass lexical variables as parameters to its functions.

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://913246]
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others avoiding work at the Monastery: (4)
As of 2016-10-23 19:31 GMT
Find Nodes?
    Voting Booth?
    How many different varieties (color, size, etc) of socks do you have in your sock drawer?

    Results (302 votes). Check out past polls.