Re: Where to put Settings-Variables?



Bernd Schneider <bernd_schneid@xxxxxx> wrote:

So I decided to put some stuff into modules.

The problem that I now come up with is:
Where do I put the variables?

Before I just declared them as:
my $mysql_host = 'localhost';
[...]

Now I have several packages and they in turn use these variables as well.

I now use a self-written script which reads the variables from a
textfile. And I put all this into a Module called Settings.pm.
So my call to a setting would be:
$Settings::value{'key'}
e.g.
$Settings::value{'mysql_host'}

But I am not too sure if this is the right way.

It is much better than using 'our'. You have them stashed
in their own namespace and thus reduced the possibility
to access them by accident.

You could create a configuration/settings object and
access configuration through method calls.

Avoid global parameters in larger programs as they make
the maintenance task really difficult.

/jUSSi

--
remove -asdf and asdf- for email address

.