B
Bill
While refactoring some perl files, I decided to put common routines in
a common file and include it with require 'file';
In order to keep variables declared in one module available in the
require file, I decided to use the 'our' keyword.
I have a question about 'use strict' syntax errors while using 'our'
with require files that contain subroutines that refer back to the
'our' variables.
See below:
####### begin file tst1.pl ######
#!/usr/bin/perl -w
use strict;
# using 'our', this is global enough to be seen by the required file
below
our $s;
require 'tst2.pl';
$s = 'world!';
printhello();
####### file ends ########
####### begin file tst2.pl ########
#### why can't I use strict here ????
#use strict;
sub printhello {
print "Hello, $s\n";
}
1;
######### file ends #######
So why can't I use strict in the require file here?
a common file and include it with require 'file';
In order to keep variables declared in one module available in the
require file, I decided to use the 'our' keyword.
I have a question about 'use strict' syntax errors while using 'our'
with require files that contain subroutines that refer back to the
'our' variables.
See below:
####### begin file tst1.pl ######
#!/usr/bin/perl -w
use strict;
# using 'our', this is global enough to be seen by the required file
below
our $s;
require 'tst2.pl';
$s = 'world!';
printhello();
####### file ends ########
####### begin file tst2.pl ########
#### why can't I use strict here ????
#use strict;
sub printhello {
print "Hello, $s\n";
}
1;
######### file ends #######
So why can't I use strict in the require file here?