my %ams_ips_hash = map {$_->{'deviceIp'}++} @{$ams_hosts}; $ams_ip = "" if !exists $ams_ips_hash{ $ams_ip};