in reply to Variable Scoping in Perl: the basics
I have two files:
# inc.pl use vars qw($foo); $foo = "hello"; 1;
If I remove the 'use vars' from t.pl than t.pl fails to run with the error 'Global symbol "$foo" requires explicit package name'. How can I create a main:: global variable in inc.pl which I can access from t.pl without explicitly listing it in a 'use vars'?# t.pl use strict; use vars qw($foo); do 'inc.pl'; print $foo, "\n";
I would like to have lots of variables in inc.pl without listing each of them in files that use them.
Thank you for any help.
In Section
Tutorials