Running test code under 'strict' (of course).
Main script 'requires' a config file, where I set the values of a bunch of variables.
Where config looks like:#!/usr/bin/perl -w use strict; use warnings; # load modules use CGI; use CGI::Carp qw(fatalsToBrowser); require 'config.pl'; my $var_1;
Perl gives me non-declaration warnings for all variables declared in the config file, but not for the ones declared in the main script.my $template_file; $template_file = "main.htm"; my $image_path; $image_path = "../../../images"; my %states; %states = ( AL => 'Alabama', AK => 'Alaska', AZ => 'Arizona' );
Double checked - no typos.
If I remove "use strict" - it runs without complaint.
If I re-instate "use strict" and move the declarations from config into the main script - it also runs without complaint.
Can I not declare variables within a 'required' file when running under 'strict'??
Thanks.
*** UPDATE ***
After some fiddling, I realized that SOME variables weren't being flagged for non-declaration. By strange coincidence, only the varaibles used in in the main script in calls to the module Template are causing Perl to complain, even after switching to using "our" instead of "my".
*** UPDATE ***
Woops - more testing shows the first update not to be true - even variables not used in calls to Template are causing probs - but not all.
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |