try use a small module to hold the servers that you need:
#-- GlobalConfig.pm
package GlobalConfig;
use Exporter;
use strict;
our @ISA=qw(Exporter);
our @EXPORT=qw($DEV_SERVER $PROD_SERVER);
our $DEV_SERVER = 'dev.server';
our $PROD_SERVER = 'prod.server';
1;
__END__
and then you can just use this module in all of your scripts:
#!/usr/bin/perl -w
use strict;
use GlobalConfig;
print "$DEV_SERVER\n";
print "$PROD_SERVER\n";
__END__
the GlobalConfig module is small and it will be loaded only once even if you
have multiple "client" scripts that use it.
david
Jason Frisvold wrote:
> Since we've finally been able to get a development machine, I find
> myself needing a quick, efficient way of pointing the programs we write
> at the correct location for the different servers they need to talk to.
> For instance, in production we use server A for the database server.
> But in development, we want to use server B since it's not a live
> database.
>
> I came up with a simple way to do this in each program by creating a
> little configuration file that looks like this :
>
> DBSERVER=servera.mydomain.com
> AUTHSERVER=serverq.mydomain.com
>
> And then using the following code to read these values into the program
> :
>
> open(CONF, "</etc/myprog.conf");
> while (<CONF>) {
> chomp;
> my ($hashname,$hashvalue) = split(/=/,$_,2);
> $self->{$hashname} = $hashvalue;
> }
> close(CONF);
>
> This works great as is. However, I wonder if there is a quick and easy
> way to do this on a global scale. I'd like to be able to have a
> "global" config file with all of the common parameters in it and then be
> able to use a module to give me only the values I need.
>
> I'd like to avoid keeping junk in memory, so it would either have to
> only read in what I need, or give me what I need so I can store it in
> local variables and then purge it's memory. (I'm a minimalist I guess
> :-))
>
> Any idea on how to do this? Thoughts? Suggestions? Code!?
>
> ---------------------------
> Jason H. Frisvold
> Senior ATM Engineer
> Engineering Dept.
> Penteledata
> RHCE - 807302349405893
> CCNA - CSCO10151622
> [EMAIL PROTECTED]
> ---------------------------
> "So Long and Thanks for all the Fish" -- Douglas Adams [1952-2001]
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]