I've been tidying up a Perl CGI script I kludged together a while ago, and one of the issues I'm having is moving config info (particularly passwords) out of of the script and into a config file outside of the web directory.
The most obvious solution to this would be App::Config, however I'm still interested why the method I attempted to use does not work.
Super Search didn't dig up what I was looking for.
I was reading Tom Christiansen's Perl Style talk and came across his suggestion to use
in the main script to read configuration information from another file of the formdo "/path/to/config/file.conf";
# Config file for a perl script. $user = 'BazB' $pass = 'yaright'; $server = 'foo.bar.com';
Unfortunately, this does not seem to work under strict.
My test script is
However it fails with#! /usr/bin/perl -w use strict; my ($server, $user, $pass); do "/home/baz/testconfig.conf"; print $server, "\n", $user, "\n", $pass, "\n";
Use of uninitialized value in print at ./readconfig.pl line 8.
I've tried playing around with the script, but the only way I can get it to 'work' is to comment out
which is bad, bad, bad. Even then, there are warnings:use strict; my ($server, $user, $pass);
(and similar for the other variables).Name "main::user" used only once: possible typo at ./readconfig.pl lin +e 8.
I certainly do not want to write a parser to read config files.
Why does using do in this manner fail?
Is there another simple way of reading configuration information without resorting to something like App::Config?
Cheers.
BazB
Edit: chipmunk 2002-02-10
In reply to Using do to read config by BazB
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |