CGI/Perl Guide | Learning Center | Forums | Advertise | Login
Site Search: in

  Main Index MAIN
INDEX
Search Posts SEARCH
POSTS
Who's Online WHO'S
ONLINE
Log in LOG
IN

Home: Perl Programming Help: Intermediate: Re: [jc1742] Accessing package variables?: Edit Log



FishMonger
Veteran / Moderator

Jul 27, 2011, 2:58 PM


Views: 4081
Re: [jc1742] Accessing package variables?

You need to use the code tags to retain the indentation.

Start by always including the stirct and warnings pragams in all of your scripts and declare all vars.

It's rarely a good idea to do what you want, but when it's appropriate, you'll want to declare $x as a global var, which is done with the 'our' keyword.

Code
our $x = 1;

Then you can access it with its fully qualified name $A::x

Prior to that, you'll need to load the module.

Code
use A;



(This post was edited by FishMonger on Jul 27, 2011, 3:00 PM)


Edit Log:
Post edited by FishMonger (Veteran) on Jul 27, 2011, 3:00 PM


Search for (options) Powered by Gossamer Forum v.1.2.0

Web Applications & Managed Hosting Powered by Gossamer Threads
Visit our Mailing List Archives