[EMAIL PROTECTED] wrote:
> for lack of a better perl vocab ill do the best I can.  I'm trying to 
> use a hash key call inside another one.  Basically getting a key from 
> one hash and using that value in another call to get a key from another 
> hash.   so something i'm doing in the syntax is incorrect.  at the end 
> of the program i demonstrate the hard coding works but the second 
> command does not.

I modified your quoting and removed unecessary quotes and added necessary ones
to make it obvious where they're needed.  Note the quoting on version field
references which contain '.'s.

use strict;
use warnings;

my $db_con = 'PROD';

my %INST= (
  PROD => {
    fullname => 'PRODUCTION',
    dbhost => {
      proddb => {
        sshcon => '',
        sshtime => 0,
      },
    },
    webhost1 => {
      prodweb1 => {
        websshcon1 => '',
        sshtime => 0,
      },
    },
    webhost2 => {
      prodweb2 => {
        websshcon2 => '',
        sshtime => 0,
      },
    },
    numweb => 2,
    version => '8.1.7',
  },
  DEV => {
    fullname => 'DEVELOPMENT',
    dbhost => {
      devweb => {
        dbsshcon => '',
        sshtime => 0,
      },
    },
    webhost1 => {
      devweb1 => {
        websshcon1 => '',
        sshtime => 0,
      },
    },
    numweb => 1,
    version => '9.2.0',
  },
);

my %QUERIES = (
  APPUSER => {
    '8.1.7' => {
      count => q{select count(*) from my_table1},
      list => q{select * from my_table1},
    },
    '9.2.0' => {
      count => q{select count(*) from my_table2},
      list => q{select * from my_table2},
    }
  }
);

print $INST{$db_con}{version} . "\n";
print "TEST 1\n" . $QUERIES{APPUSER}{'9.2.0'}{count} . "\n";
print "Attempt to retreive version number from second reference that " .
  "relies on the value of $db_con\n";
print "TEST 2\n" . $QUERIES{APPUSER}{$INST{$db_con}{version}}{count} . "\n";

__END__


-- 
  ,-/-  __      _  _         $Bill Luebkert    Mailto:[EMAIL PROTECTED]
 (_/   /  )    // //       DBE Collectibles    Mailto:[EMAIL PROTECTED]
  / ) /--<  o // //      Castle of Medieval Myth & Magic http://www.todbe.com/
-/-' /___/_<_</_</_    http://dbecoll.tripod.com/ (My Perl/Lakers stuff)
_______________________________________________
Perl-Unix-Users mailing list
Perl-Unix-Users@listserv.ActiveState.com
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs

Reply via email to