Just another Perl shrine | |
PerlMonks |
Re: Variables in a single fileby leocharre (Priest) |
on Sep 16, 2009 at 16:00 UTC ( [id://795654]=note: print w/replies, xml ) | Need Help?? |
Well, what is your code? Is it a script only?
Then here's one example..
In that example, the variables reside in namespace main::, so that from anywhere in the program, $main::AGE will hit 29 in this example. If this were a module..
Then from anywhere in the code (there are some variations), you can access $Sunflower::AGE. (You do have to realize that if you code a module (pm), then that example there, those values are set at compile time, before your code calling 'use Sunflower;' runs.. Worry about this later.) I would say if you expect your values to change from time to time.. How about a YAML config file?
And in your /etc/sunflower.conf.. --- AGE: 29 NAME: jim
In Section
Seekers of Perl Wisdom
|
|