I had this same question answered on the perl beginners list.  Object
oriented programming was recommended.  Someday I want to learn about
that
But for now what I did was give the configuration file and the scripts
that use it the same package name and then I defined these variables as
global
Variables with the use vars.   It works ok with the use strict, but it
may
Violate some standard perl coding practices against global variables. 
Maureen  

-----Original Message-----
From: Octavian Rasnita [mailto:[EMAIL PROTECTED]] 
Sent: Friday, June 07, 2002 12:12 AM
To: [EMAIL PROTECTED]
Subject: Using strict and a configuration file?

Hi all,

Is it possible to use "use strict;" if I get the variables from a
configuration file?

I've tried:

use strict;
require "f:/xxx/config.txt";

#In the configuration file I have a line like my $test = "test test
test";

print "Content-type: text/html\n\n";
print $test;

This gives me an error that I should define the variable $test.
I don't want to define it in the script but in the configuration file.
However, if I define it in the script with my $test; the script prints
an
empty string and doesn't take the variable from the configuration file.

Is it possible to use strict, or it is necessary to use "no strict;?

Another problem, maybe bigger is that  even though the script is running
fine,  it give me errors in the log file telling me that the variable
$xxx
and $yyy, ... is used only once.

Is there a good method to define variables for more scripts in  a single
configuration file?
I don't want to store my email address and other settings in each script
because I may change that address, and then I will need to modify a lot.

Thank you.
..... or I have another solution for defining all the variables in a
configuration file?


Teddy,
[EMAIL PROTECTED]






-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to