[Melbourne-pm] Using strict...

Tim Hunt tim.hunt at bom.gov.au
Mon Feb 19 19:44:58 PST 2007


Hi All;

I am updating *old* cgi-bin scripts to _use strict_.

The original author had a suite of config files A.cfg, B.cfg etc. that
were parsed at run time to declare variables.

for example:
# A.cfg

$foo = 'hello world';
$bar = 3;

##

#Main script:

# Read the config file and execute each line in it as a perl statement;
print "config_file is.. $config_file\n";
open(IN, $config_file) || &my_die("Can't open config file:
\"$config_file\": $!");

while (<IN>){
   eval(&untaint($_));
   if ($@){
      my_warn($@);
   }
}
close(IN);

print $foo;

############

Of course, with strict on, this does not work as the variables are all
confined  to the scope of the eval(config_line).

My options seem to be to declare all the variables in the main script
and carry on regardless, or implement a better config method. 

Discussion appreciated.

Cheers,
Tim.


More information about the Melbourne-pm mailing list