I wrote this late at night, pretty sure it will work out, though my comments -may- be off a little, maybe someone can correct me on any wrong points. We're all here to learn.
Code:
%HoH = (
'leather' => {
'head' => 147587,
'chest' => 147588,
'legs' => 147591,
},
'plate' => {
'head' => 147580,
'chest' => 147581,
'legs' => 147584,
},
'chain' => {
'head' => 147573,
'chest' => 147547,
'legs' => 147577,
},
'cloth' => {
'head' => 147566,
'chest' => 147567,
'legs' => 147570,
},
);
sub EVENT_SAY
{
if ($text=~/hasharmorset/i)
{
# doing the following assuming the player is wearing a plate head (ID 147580)
foreach $firstlevelkey (keys %HoH)
{
# iterate the parent keys of hash %HoH one by one and put the current key being read into $parentkey
# we will assume 'plate' was read first
$childhashref = $HoH{$firstlevelkey};
# make reference of first level hash based on current parent key (i.e. $parentkey)
# $childhashref now equals $HoH{plate}
foreach $secondlevelkey (keys %$childhashref)
{
# iterate the second level (child) keys of the dereferenced hash and put that key into $secondlevelkey
# could also be written %{$childhashref} - lets assume it pulls out the key 'head' from $HoH{plate}
if ($client->GetItemIDAt(2) == $HoH{$firstlevelkey}->{$secondlevelkey})
{
# $HoH{plate}->{head} is equal to its key value which is 147580 - a match, we know they have plate this iteration
quest::say("You are wearing a ".$firstlevelkey." ".$secondlevelkey." found within my Hash of Hashes");
}
}
}
}
}