DNSサーバーに転送されるIPアドレスを入力した後、ホスト名を検索できるスクリプトがあります。
ただし、すべてが正常に機能していても、DNSが見つからない場合、プログラムは例として必要なエラーを出力できないようです。
コード:
#!/usr/bin/perl
use IO::Socket;
use warnings;
use strict;
use Term::ANSIColor;
use Socket;
use Sys::Hostname;
print "\nYou are now in Show DNS IP Address!\n\n";
print "*************\n";
print "|DNS Address|\n";
print "*************\n";
print "\nPlease enter a hostname that you wish to view\n\n";
print "\n\nEnter the hostname of Choice Here: ";
my $userchoice = <>;
chomp ($userchoice);
my $host = hostname();
my $hostname = $userchoice;
my $packed_ip = gethostbyname("$hostname");
my $ip_address = inet_ntoa($packed_ip) or system("clear"), system("/root/Desktop
/showdns.pl"), die("Can't resolve $hostname: $!\n ,try again");
my $coloredText = colored($name, 'bold underline blue');
print "\n\nThe hostname IP address is: $coloredText\n\n";
print "Press enter to go back to the main menu\n\n";
my $userinput2 = <>;
chomp ($userinput2);
system("clear");
system("/root/Desktop/simpleip.pl");
誰かがコードについてアドバイスをいただけますか?