use strict; use warnings FATAL => 'all'; my %dns_check = (address => 'ip'); while (my ($key, $value) = each %dns_check) { my $found_addr = gethostbyname($key) or die "Error $!\n"; $found_addr = inet_ntoa(inet_aton($key)); print "IP found is: $found_addr\n"; }