As you can see what I want to know is how do I make it so that $sth is accessible across all files (without having to do use vars qw// at the top of every file, or something similar).
Also, I was wondering if anyone could help me with this:
Just like above, I would like to know is there an easy way to have MY_CONSTANT accessible from every file that the program uses. If there is not, and I decided to add 'use configuration' in every file would that really be like using X many more files or would it just open up the name space. Phrased Differently: If I were to place 'use configuration' at the top of every file would it require more RAM?
You can always call a variable with a fully qualified package name.
For example, you can have the $sth variable defined in your main script and then call it from any other package that you "require" like this:
Code:
$main::sth
Or, alternatively, you can use the same package in all required files. If you will use the same package then all the files will share the same name space and thus a variable defined in one of the files will be also accessible in other files from the same package.
You question about importing configuration variable is basically the same. Perl compiles one file only once, the next time you try to "require" it or "use" it will just "open the name space" like you have written.
Bookmarks