I have an hash map like this
my $name = \'AUS\'; #dynamic values
my %hash = { \'a\'=>{
\'x\'=> {
\'1\' =>\'US
if I understand correctly you want something like this:
use strict;
use warnings;
my $name = 'AUS'; #dynamic values
my %hash = ( 'a'=>{
'x'=> {
'1' =>'US',
'2' =>'UK'
},
'y'=>{
'1' =>'AFRICA',
'2' =>'AUS'
}
},
'b'=>{
'x' =>{
'1' =>'US',
'2' =>'UK'
}
}
);
my @val = grep {$_ eq $name} map {my $x=$_; map {my $y=$_; map {$hash{$x}->{$y}->{$_}} keys %{$hash{$x}->{$_}}} keys %{$hash{$_}}} keys %hash;
if(@val == 0) {
print "$name not found";
}
elsif(@val == 1) {
print "$name is unique";
}
else {
print "$name is not unique";
}