v_o_i_d has asked for the wisdom of the Perl Monks concerning the following question:

Hi monks, I'm having this problem that I find very confusing, but which (I'm certain) has an easy answer which I can't find specifically addressed in the Q&A section or elsewhere.

Basically I have a perl library (.pl) file. In it I declare a global variable our $var to be used in other modules via require etc. I also use strict; and use warnings;. In my perl module (.pm) this warning appears when I start using the 'global' variable: Global symbol "$var" requires explicit package name...

When I remove the use strict this error does not appear, but I suspect that the problem remains. Am I right in believing the $var variable is being re-declared in the perl module or has it become local to the perl module file, and the declaration our $var in the perl library file is ignored?

All I want to do is use the straight $var in other files and for $var to act like a true global variable.

simple code mock-up: use strict; use warnings; our $var = 1; #------------------ use strict; use warnings; require ''; $var = 2; # <-- This doesn't work, but it is supposed to be global, + right? #------------------