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

  Main Index MAIN
Search Posts SEARCH
Who's Online WHO'S
Log in LOG

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

Veteran / Moderator

Jul 27, 2011, 2:58 PM

Views: 6599
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.

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.

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