I have a module that provides some global variables and a few common subs. Some of the variables are set to default values. I presume I can assume that the values will be set before any code that uses the module can call any of the subs in the module. Is that a safe assumption if there are no BEGIN blocks involved? Example:
use strict; use warnings; package noname; require Exporter; our @ISA = ('Exporter'); our @EXPORT = qw($globalVariable UseVariable); my $globalVariable = 'Default value'; sub UseVariable { print $globalVariable; } 1; package main; noname::UseVariable ();
Prints:
If package main is in another file can this code bite me ($globalVariable used before it is initialised)?Default value
In reply to Compile order sanity check by GrandFather
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |