On Thu, 17 Mar 2005 08:46:55 -0600, Dave Kettmann wrote:
> 
> --<snip>--
> 
> open (CFG, "/etc/backup.conf") or die "Can't open config file: $!\n";
>   while (<CFG>) {
>   }
> close CFG;
> 
> --<END>--
> 
> Ok so when I run my program like this .. it complains on the the open() line 
> and the close() line. 
> It says:
> 
> Bareword "CFG" not allowed while "strict subs" in use at backup-client.pl 
> line 27.
> Bareword "CFG" not allowed while "strict subs" in use at backup-client.pl 
> line 37.
> 

Hi Dave,
The code looks okay (read "perldoc -f open" to prove to yourself that
CFG is allowed where you put it), so it must be a problem in another
part of the code. Could you show the part you snipped?

One other comment- you seem to be rolling your own
"configuration-file-reader" solution. Why re-invent the wheel? The are
many good configuration-related modules on CPAN. I suggest
Config::Auto for its simplicity of use:
######## begin perl code #########
use Config::Auto;
my $User_Preferences = Config::Auto::parse("/etc/backup.conf");
# $User_Preferences is now a reference to a hash holding your configuration data
######## end perl code #########

To install Config::Auto, write on the command-line:
$ perl -MCPAN -e shell

and inside the CPAN shell write:
cpan> install Config::Auto

Hope this helps.
-- 
Offer Kaye

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>


Reply via email to