Unless your code is in the same package as the global, you need to give the full package name to access global variables defined by our (also use vars):<br><br>$ cat <a href="http://Foo.pm">Foo.pm</a><br>package Foo;<br><br>
our $GLOBAL;<br><br>sub set_foo { $GLOBAL = &#39;foo&#39; }<br>1;<br>$ cat <a href="http://Bar.pm">Bar.pm</a><br>package Bar;<br><br>sub set_bar { $Foo::GLOBAL = &#39;bar&#39; }<br>1;<br>$ cat test.pl<br>#!/usr/bin/perl -w
<br><br>use strict;<br><br>use lib qw(./);<br><br>use Foo;<br>use Bar;<br><br>print &quot;GLOBAL = $Foo::GLOBAL\n&quot;;<br><br>Foo-&gt;set_foo;<br>print &quot;GLOBAL = $Foo::GLOBAL\n&quot;;<br><br>Bar-&gt;set_bar;<br>print &quot;GLOBAL = $Foo::GLOBAL\n&quot;;
<br>$ perl test.pl<br>Use of uninitialized value in concatenation (.) or string at test.pl line 10.<br>GLOBAL =<br>GLOBAL = foo<br>GLOBAL = bar<br><br><div><span class="gmail_quote">On 3/8/07, <b class="gmail_sendername">
<a href="mailto:nheller@silcon.com">nheller@silcon.com</a></b> &lt;<a href="mailto:nheller@silcon.com">nheller@silcon.com</a>&gt; wrote:</span><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
<br>Following is a cut-down version of what I&#39;m trying to do.<br>The problem I&#39;m having is that the variable, $intendedDest, is not holding<br>its value from the called code (in Navigate.pl) to the calling code<br>
(Migrate.pl).<br><br>Can somebody help?<br><br><br># ===== Migrate.pl =====<br><br>#!Perl&nbsp;&nbsp;-w<br><br>use strict;<br>use warnings;<br><br>my $ccDir = $ARGV[0];<br>my $currentLocation = &quot;c:\\ADO_new&quot;;<br>require $currentLocation . &quot;\\Navigate.pl&quot;;
<br><br>our $intendedDest = 0;<br><br>Nav_to_start::Navigate($ccDir);<br><br><br><br><br>#&nbsp;&nbsp;===== Navigate.pl =====<br><br>package Nav_to_start;<br><br>use Fcntl &#39;:mode&#39;;<br><br>BEGIN { }<br><br>&nbsp;&nbsp;&nbsp;&nbsp;sub Navigate {
<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;my $choiceResponse = &lt;STDIN&gt;;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;chomp($choiceResponse);<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;$intendedDest = $choiceResponse;<br>&nbsp;&nbsp;&nbsp;&nbsp;}<br>&nbsp;&nbsp;&nbsp;&nbsp;return 1;<br>END { }<br><br><br><br><br><br><br><br>&gt; <a href="mailto:nheller@silcon.com">
nheller@silcon.com</a> wrote:<br>&gt;&gt; I&#39;m trying to create a variable that is visible in multiple namespaces.<br>&gt;&gt; I tried declaring the variable using &quot;our&quot;.<br>&gt;&gt; With use strict in effect, the code seems to treat the variable as a
<br>&gt;&gt; local<br>&gt;&gt; in each place that it&#39;s used.&nbsp;&nbsp;IOW, it doesn&#39;t hold value from one<br>&gt;&gt; namespace to the next.<br>&gt;&gt; Can anybody tell me where I&#39;m going wrong?<br>&gt;<br>&gt; Can you show us the code which demonstrates what you&#39;re trying to
<br>&gt; accomplish?<br>&gt; _______________________________________________<br>&gt; SanFrancisco-pm mailing list<br>&gt; <a href="mailto:SanFrancisco-pm@pm.org">SanFrancisco-pm@pm.org</a><br>&gt; <a href="http://mail.pm.org/mailman/listinfo/sanfrancisco-pm">
http://mail.pm.org/mailman/listinfo/sanfrancisco-pm</a><br>&gt;<br><br>_______________________________________________<br>SanFrancisco-pm mailing list<br><a href="mailto:SanFrancisco-pm@pm.org">SanFrancisco-pm@pm.org</a><br>
<a href="http://mail.pm.org/mailman/listinfo/sanfrancisco-pm">http://mail.pm.org/mailman/listinfo/sanfrancisco-pm</a><br></blockquote></div><br>