Tuna has asked for the wisdom of the Perl Monks concerning the following question:
What I'm struggling with is, I need to test for the existence of "$cluster.hosts" in %HoL{$cluster}#!/usr/bin/perl -w use strict; my @configs; my $path = "/some-path"; my @clusterDirList = ("$path/cluster1", "$path/cluster2", "$path/clust +er3"); my %hash = ( 'remap.config' => 'remap.config.hosts:user|SApre-push.pl|NA', 'origin.db' => 'origin.db.hosts:user|SApre-push.pl|NA', 'local_cluster.db' => :user|SApre-push.pl|NA' ); my %HoL = ( 'cluster1' => [ 'remap.config', 'remap.config.hosts', 'origin.db', 'origin.db.hosts', 'local_cluster.db', 'local_cluster.hosts ] ); foreach my $key(keys %hash) { push @configs, $key; } foreach my $cluster (@clusterDirList) { foreach my $configfile (@configs) { push @{ $HoL{$cluster} } , $configfile; } }
In other words, I need to determine whether or not, ie, "remap.config.hosts" is one of the multiple values stored in %HoL{$cluster}.
Can anyone shed some light on this?
Thanks,
Steve
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: TestIs hash key a value contained in a hash of arrays?
by runrig (Abbot) on Aug 07, 2001 at 01:17 UTC | |
|
Re: TestIs hash key a value contained in a hash of arrays?
by tachyon (Chancellor) on Aug 07, 2001 at 01:31 UTC | |
|
Re: TestIs hash key a value contained in a hash of arrays?
by Zaxo (Archbishop) on Aug 07, 2001 at 01:30 UTC |