G
guytew
First off, apologies if what I'm trying to parse is not a multi-
dimensional hash - I'm still confused even having read the perldoc and
numerous usenet postings :-(
I am using a perl module to store various configurations [see snippet
below]. I want to be able to create an array called @sids that
contains the keys ZA1, YB4, XMM so that I can loop through the array
and retrieve Description, Ports or whatever using. It seems all the
variations for retrieving keys from the simple
keys %Instances to the convoluted display nothing! I'm successfully
using the Config when I know the keys, but now I need to build a list
to work from. Any solutions gratefully received.
foreach $sid (@SIDS) {
my $port = $BASIS::Config::Instances{$sid}{Ports}
# do something with the retrieved value
}
[ snippet from my Config package ]
package BASIS::Config;
use strict;
use vars qw( %Alerts %Instances %Servers );
%Instances = (
ZA1 => {
Description => "Production",
Ports => '3300 3200',
},
YB4 => {
Description => "Quality",
Ports => '3300 3200',
},
XMM => {
Description => "Development",
Ports => '3300 3200',
},
);
dimensional hash - I'm still confused even having read the perldoc and
numerous usenet postings :-(
I am using a perl module to store various configurations [see snippet
below]. I want to be able to create an array called @sids that
contains the keys ZA1, YB4, XMM so that I can loop through the array
and retrieve Description, Ports or whatever using. It seems all the
variations for retrieving keys from the simple
keys %Instances to the convoluted display nothing! I'm successfully
using the Config when I know the keys, but now I need to build a list
to work from. Any solutions gratefully received.
foreach $sid (@SIDS) {
my $port = $BASIS::Config::Instances{$sid}{Ports}
# do something with the retrieved value
}
[ snippet from my Config package ]
package BASIS::Config;
use strict;
use vars qw( %Alerts %Instances %Servers );
%Instances = (
ZA1 => {
Description => "Production",
Ports => '3300 3200',
},
YB4 => {
Description => "Quality",
Ports => '3300 3200',
},
XMM => {
Description => "Development",
Ports => '3300 3200',
},
);