my %INST= (
PROD => {
fullname=> "PRODUCTION",
dbhost => "proddb",
dbsshcon=> "",
webhost1=> "prodapp",
websshcon1 => "",
version => "8.1.7",
},
DEV => {
fullname=> "DEVELOPMENT",
dbhost => "devdb",
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...
DEV => {
fullname=> "DEVELOPMENT",
Martin, thanks for the response. Yes there are multiple servers and I tried to
simplify the code since I wasn't providing a full script. This can also help
me minimize hard coding throughout the script.
- Original Message -
From: Martin Moss <[EMAIL PROTECTED]>
Date: Monday, April 4, 2
--- [EMAIL PROTECTED] wrote:
> Martin, thanks for the response. Yes there are
> multiple servers and I tried to simplify the code
> since I wasn't providing a full script. This can
> also help me minimize hard coding throughout the
> script.
Avoiding hard coding - always a good thing... :-)
Whe
> 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 hard
> You might consider
> creating a config file that your script reads and builds the
> hash dynamically.
Agreed. And YAML is perfect for this kind of thing. Why?
- YAML is easily human-readable and editable (compared
to, say, XML)
- YAML can represent _any_ arbitrary Perl data structure.
With this new structure, how would I dereference the hash to return the text
value instead of the hash reference?
use strict;
my %INST= (
DEV => {
fullname=> "DEVELOPMENT",
dbhost => { "erpd3" => {
sshcon => "",
print "my hash value is '".$INST{DEV}->{dbhost}."'\n";
--- [EMAIL PROTECTED] wrote:
> With this new structure, how would I dereference the
> hash to return the text value instead of the hash
> reference?
>
> use strict;
>
> my %INST= (
> DEV => {
>fullname=> "DEVELOPMENT",
>