my $addr = inet_aton($input); die "invalid hostname specified\n" if ! $addr; my $ip = inet_ntoa($addr); ...