in reply to Require Centralized Variables
The only problem, is strict screams about the variable not being declared.That's because strict requries variables to be declared or fully qualified. So your script will work if you qualify $foo as being in the main package e.g
There we qualified it with the preceding double colon (which is a shorter way of saying main::).shell> cat > tmp.pl $foo = "a string"; 1; ^D shell> perl -e 'use strict; require "tmp.pl"; print $::foo, "\n"' a string
As for lexical variables declared in another file, they will fall out of scope at the end of a require, as they will no longer be in the file scope as demonstrated in the lexical scoping tutorial. You might also want to check out the first half of the <plug>symbol tables and globs tutorial</plug> for more info on package variables.
HTH
_________
broquaint
|
|---|