[sf-perl] Scope of a variable
nheller at silcon.com
nheller at silcon.com
Thu Mar 8 13:08:30 PST 2007
Following is a cut-down version of what I'm trying to do.
The problem I'm having is that the variable, $intendedDest, is not holding
its value from the called code (in Navigate.pl) to the calling code
(Migrate.pl).
Can somebody help?
# ===== Migrate.pl =====
#!Perl -w
use strict;
use warnings;
my $ccDir = $ARGV[0];
my $currentLocation = "c:\\ADO_new";
require $currentLocation . "\\Navigate.pl";
our $intendedDest = 0;
Nav_to_start::Navigate($ccDir);
# ===== Navigate.pl =====
package Nav_to_start;
use Fcntl ':mode';
BEGIN { }
sub Navigate {
my $choiceResponse = <STDIN>;
chomp($choiceResponse);
$intendedDest = $choiceResponse;
}
return 1;
END { }
> nheller at silcon.com wrote:
>> I'm trying to create a variable that is visible in multiple namespaces.
>> I tried declaring the variable using "our".
>> With use strict in effect, the code seems to treat the variable as a
>> local
>> in each place that it's used. IOW, it doesn't hold value from one
>> namespace to the next.
>> Can anybody tell me where I'm going wrong?
>
> Can you show us the code which demonstrates what you're trying to
> accomplish?
> _______________________________________________
> SanFrancisco-pm mailing list
> SanFrancisco-pm at pm.org
> http://mail.pm.org/mailman/listinfo/sanfrancisco-pm
>
More information about the SanFrancisco-pm
mailing list