in reply to strict, debug and global variables
You can create a package with package global variables in it, and get at those variables using their fully-qualified name, like this:
First, just name this one MyConfig.pm:
package MyConfig; use strict; use warnings; our $testvar = "Hello world."; 1;
And now in MyScript.pl:
#!/usr/bin/perl use strict; use warnings; use MyConfig; print $MyConfig::testvar, "\n";
Using the fully qualified variable name means you won't be exporting it directly into your main script's namespace, you'll just be accessing the configuration package's namespace. That's a pretty easy way to do it.
Dave
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: strict, debug and global variables
by Aristotle (Chancellor) on Sep 17, 2004 at 00:09 UTC | |
by davido (Cardinal) on Sep 17, 2004 at 00:51 UTC |