Here is the whole first part. Snipped part is just declaration of variables.
The reason I'm 'reinventing the wheel' is for compatibility across systems that dont have the module installed. I'm trying to get away with installing as few extra modules as possible. --<CODE>-- #!/usr/bin/perl # March 10, 2005 use strict; use warnings; use Sys::Hostname; use Time::localtime; use File::Remote qw(:replace); setrsh('/usr/bin/ssh'); setrcp('/usr/bin/scp'); settmp('/tmp'); my (%User_Preferences, $var, $value); my @directories; my $ext = ".tar.bz"; my $host = hostname; my $t = localtime(); my $mday = $t->mday; my $mon = $t->mon; my $year = $t->year; $year= $year + 1900; my $date = "$mon.$mday.$year"; my $tarprg; my $cfg_file = "/etc/backup.conf"; open (*CFG, $cfg_file) or die "Can't open config file: $!\n"; while (<CFG>) { chomp; s/#.*//; s/^\s_//; s/\s+$//; next unless length; ($var, $value) = split(/\s*=\s*/, $_, 2); $User_Preferences{$var} = $value; } close *CFG; --<snip to end>-- --</CODE>-- Thanks again for help. Dave Kettmann NetLogic 314-266-4000 > -----Original Message----- > From: Offer Kaye [mailto:[EMAIL PROTECTED] > Sent: Thursday, March 17, 2005 9:14 AM > To: Perl Beginners > Subject: Re: Type-globbing filehandles > > > 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> > > > -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] <http://learn.perl.org/> <http://learn.perl.org/first-response>