I assume that the
my $var = $main::var;line is outsode of any subroutine in your module. In that case the code is executed when the module is loaded. All "use" statements are executed at compile time - this is before $main::var has been given a value.
The quick fix is to put the line into a BEGIN block.
BEGIN { $main::var = "value"; }But you should probably look for a more elegant solution.
--"The first rule of Perl club is you do not talk about
Perl club."
-- Chip Salzenberg
In reply to Re: Packages and modules
by davorg
in thread Packages and modules
by Anonymous Monk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |