J
John Smith
We have global_vars.pl which defines:
$foo = "/abc/def/hij/";
We then have temp.pl which uses $foo as follows:
#!/usr/bin/perl -w
require "./mxrt_vars.pl";
use strict;
print "$foo\n";
../temp.pl
Global symbol "$foo" requires explicit package name at ./temp.pl line
10.
Execution of ./temp.pl aborted due to compilation errors.
If I try declaring $foo in temp.pl as follows:
#!/usr/bin/perl -w
require "./mxrt_vars.pl";
use strict;
my $foo;
print "$foo\n";
./temp.pl
Use of uninitialized value at ./temp.pl line 10.
I have also tried changing $foo to my $foo in global_vars.pl; I still
got an error.
What is the correct way to use $foo, which is included in
global_vars.pl?
$foo = "/abc/def/hij/";
We then have temp.pl which uses $foo as follows:
#!/usr/bin/perl -w
require "./mxrt_vars.pl";
use strict;
print "$foo\n";
../temp.pl
Global symbol "$foo" requires explicit package name at ./temp.pl line
10.
Execution of ./temp.pl aborted due to compilation errors.
If I try declaring $foo in temp.pl as follows:
#!/usr/bin/perl -w
require "./mxrt_vars.pl";
use strict;
my $foo;
print "$foo\n";
./temp.pl
Use of uninitialized value at ./temp.pl line 10.
I have also tried changing $foo to my $foo in global_vars.pl; I still
got an error.
What is the correct way to use $foo, which is included in
global_vars.pl?