I'm writing a module. In scripts that use the module I need to communicate some information from the script to the module.
At least for the time being my plan was to define a global variable in the main package in the script that uses the module, then read the value of that variable in the module, e.g.:
SCRIPT
------
$main::var = "value"; use MyModule;
MODULE
------
package MyModule; my $var = $main::var;
I tried that and was shocked to find that $main::var is undefined to the code in my module.
It was my understanding that there is a package, main (always referred to in the literature as "the main package" or "package main"), whose variables could be accessed from anywhere using the fully qualified syntax. That doesn't seem to be the case -- what's going on?
I'd also appreciate information about what is the usual or best way to get data to a module from the code using the module.
Thanks,
JMM
In reply to Packages and modules by Anonymous Monk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |