title: perl declare and export variables from a module
body: <p>I need to modify a bunch of scripts to do the equivalent of a straight C style &quot;include&quot; of a moderate number of variables.  After the &quot;use&quot; to pull these in it should act exactly as if a line like this had been included:</p>
  <pre><code>my $os_name = &quot;Windows&quot;; #declares the variable AND sets its value
  </code></pre>
  <p>So that they may be used in the &quot;calling&quot; script. There is a little bit of logic in the module that conditionally sets the values of these variables. The scripts all have &quot;use strict&quot;.   A typical &quot;caller&quot; has:</p>
  <pre><code>use strict;
  use File::Basename;
  use lib dirname (__FILE__);
  use os_specific;
  print &quot;DEBUG os_name $os_name\n&quot;;
  </code></pre>
  <p>and the module (os_specific.pm) has:</p>
  <pre><code>package os_specific;
  use warnings;
  use strict;
  use Exporter;
  our @EXPORT = qw($os_name);
  our $os_name=&quot;Windows&quot;;
  1
  </code></pre>
  <p>But it doesn't work, there are compile stage warnings like:</p>
  <pre><code>Global symbol &quot;$os_name&quot; requires explicit package name at caller.pl.
  </code></pre>
  <p>So the declaration of the variable in the module is not effective at the caller's scope.</p>
  <p>Can this be done, or must each of these variables also be declared in caller.pl?  (All responses please employ &quot;use strict&quot; - without that it can be done using a &quot;require&quot;.  That doesn't work with &quot;use strict&quot; though because it throws a compile time error.)</p>
  <p>I know the variables from the module can be used as &quot;$os_specific::os_name&quot;, the question is how to set this up so that they can be used as just &quot;$os_name&quot;.</p>
  <p>Thanks.</p>