kwatts59 has asked for the wisdom of the Perl Monks concerning the following question:
Program a.pl
use strict; use warnings; our ($database); $database = "test1";
Program b.pl
use strict; use warnings; our ($database); $database = "test2";
Program c.pl
require "a.pl"; print "$database\n"; require "b.pl"; print "$database\n"; require "a.pl"; print "$database\n";
The output from program c.pl is as follows:
test1 test2 test2
I would like the output to be as follows:
What am I doing wrong?test1 test2 test1
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Variable scoping problem
by haukex (Archbishop) on Nov 25, 2019 at 22:25 UTC | |
|
Re: Variable scoping problem
by hippo (Archbishop) on Nov 25, 2019 at 22:29 UTC | |
by haukex (Archbishop) on Nov 25, 2019 at 22:50 UTC | |
by kwatts59 (Novice) on Dec 04, 2019 at 14:45 UTC | |
|
Re: Variable scoping problem (how is my program running)
by Anonymous Monk on Nov 26, 2019 at 00:35 UTC | |
|
Re: Variable scoping problem
by BillKSmith (Monsignor) on Nov 27, 2019 at 03:47 UTC | |
|
Re: Variable scoping problem
by Anonymous Monk on Nov 26, 2019 at 01:58 UTC | |
by Anonymous Monk on Nov 26, 2019 at 15:49 UTC |