in reply to Packages and modules

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.

--
<http://www.dave.org.uk>

"The first rule of Perl club is you do not talk about Perl club."
-- Chip Salzenberg