in reply to including variables
all of the module structureIf you only want to share a variable, the module structure isn't that heavy:
Now with use or require of MyModule, you can access $MyModule::variable. (our actually creates an alias so that $variable points to $MyModule::variable inside the MyModule.pm file).package MyModule; our $variable = "This variable is visible outside";
Otherwise, if your file only contains the data, and no definition, for example:
You can use do like this: my $data = do "./data.pl"; (ie, the definition of the variable in the calling script, that way each script using the data can define its own name).# data.pl { Stuff => 1 }
Edit: "./data.pl" is better than "data.pl" because do searches in the folders of @INC, which does not contain the current one by default in perl >= v5.26
|
|---|