> I think this is what you're trying to do....
>
> But I'm not sure why? I'd only do this if you are
> expecting to have multiple configs for dbhost, e.g.
> devdb1, devdb2, devdb3... otherwise I'm not sure why
> you'd break down the structure this much...
>
Agreed. Also, by building it in a hardcoded hash of hashes it makes it
harder to maintain (read: easier to break) as you add/remove servers or
change settings. You might consider creating a config file that your script
reads and builds the hash dynamically.
Might look something like:
my $inst;
my %hash;
foreach(<DATA>)
{
chomp($_);
my ($key,$value) = split(/\=/,$_);
if ($key eq 'INST')
{
$inst = $value;
}
else
{
$hash{$inst}{$key}=$value;
### You could also build additional rules to created deeper
### hashes if desired
}
}
__DATA__
INST=PROD
fullname=PRODUCTION
dbhost=proddb
dbsshcon=""
webhost1=prodapp
websshcon1=""
version=8.1.7
INST=DEV
fullname=DEVELOPMENT
dbhost=devdb
dbsshcon=""
webhost=devapp
numweb=1
version=8.1.7
_______________________________________________
Perl-Unix-Users mailing list
[email protected]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs