Use of uninitialized value at C:/PERL/site/lib/Net/Whois.pm line 288 (#1) Use of uninitialized value at C:/PERL/site/lib/Net/Whois.pm line 289 (#1) Use of uninitialized value at C:/PERL/site/lib/Net/Whois.pm line 294 (#1) Use of uninitialized value at C:/PERL/site/lib/Net/Whois.pm line 297 (#1) #### #!/perl -w # tk_whois_perl.pl # july, 2001 # uses the Net::Whois module to query the Internic DNS for domain names # uses Tk for input and output display # warning message first time an unfound match, # thereafter no message just the not found message box # #Use of uninitialized value at C:/PERL/site/lib/Net/Whois.pm line 288 (#1) #Use of uninitialized value at C:/PERL/site/lib/Net/Whois.pm line 289 (#1) #Use of uninitialized value at C:/PERL/site/lib/Net/Whois.pm line 294 (#1) #Use of uninitialized value at C:/PERL/site/lib/Net/Whois.pm line 297 (#1) # #fgsgsdgsdg.com not found # from the whois documentation - Note that all fields except ``name'' and ``tag'' # may be undef because ``whois'' information is erratically filled in. use diagnostics; use strict; use Tk; use Tk::widgets qw/Dialog/; require Tk::ROText; #require Tk::LabEntry; use Net::Ping; use Net::Whois; #------------------------------------------------- my $main = new MainWindow; my $domain_input_entry; my $domain_output_text_box; online_test(); init(); MainLoop; #------------------------------------------------- sub online_test { my $online_check = check_if_online(); if ( $online_check eq "N" ) { $main->withdraw; # do not show my $msgbox_not_online_text = "\n\nmust be online to use whois\n\nreturn to menu to dialup\n"; my $msgbox_not_online = $main->messageBox(-icon => 'warning', -message => "$msgbox_not_online_text", -title => 'not online', -type => 'OK'); $main->destroy; exit; } } # end of online_test #------------------------------------------------- sub init { # create frame and input label and entry; submit and exit whois buttons my $input_frame = $main->Frame(qw/-width 450 -height 250/)->pack; my $domain_info_label = $input_frame->Label(-text => 'lookup whois information from the InterNIC server'); my $domain_input_label = $input_frame->Label(-text => 'enter domain name to search for'); $domain_input_entry = $input_frame->Entry(-width => 25); # to bind the pressing of enter key to the domain_sub as the button does in -command $main->bind('' => sub{check_input_entry($domain_input_entry)}); my $input_button = $input_frame->Button(-text => 'submit', -width => 6, -command => sub{check_input_entry($domain_input_entry)}); my $exit_button = $input_frame->Button(-text => 'exit', -width => 6, -command => sub{exit}); # pack $domain_info_label->pack(-side => 'top', -fill => 'both', -expand => 1); $domain_input_label->pack(-side => 'left', -expand => 1); $domain_input_entry->pack(-side => 'left', -expand => 1); $exit_button->pack(-side => 'right', -expand => 1, -anchor => 'e', -padx => 6, -pady => 2); $input_button->pack(-side => 'right', -expand => 1, -anchor => 'e', -padx => 6, -pady => 2); # create the frame for the output text my $output_frame = $main->Frame(qw/-width 450 -height 300 -background gray/)->pack; $domain_output_text_box = $output_frame->ROText(-relief => 'sunken', -width => 60, -height => 15, -wrap => 'word', -setgrid => 1); my $scroll = $output_frame->Scrollbar(-command => ['yview', $domain_output_text_box]); $domain_output_text_box->configure(-yscrollcommand => ['set', $scroll]); $domain_output_text_box->pack(-side => 'left', -fill => 'both', -expand => 1); $scroll->pack(-side => 'right', -fill => 'y'); $domain_input_entry->focus; # set the focus to the entry box } # end init #------------------------------------------------- sub check_input_entry { my($widget) = @_; my $domain_name = $widget->get(); chomp($domain_name); if ( $domain_name =~ /(.org|.com|.edu|.net$)/ ) { # domain type was acceptable, so pass the domain_sub($domain_name); # domain name to the domain_sub to contact clear_entry(); # the whois server } else { my $msgbox_unacceptable_domain_entered_text = "\n\ndomain name must end in .org, .com, .edu or .net\n\nenter domain or exit whois\n\n"; my $msgbox_unacceptable_domain_entered = $main->messageBox(-icon => 'warning', -message => "$msgbox_unacceptable_domain_entered_text", -title => 'unacceptable domain type entered', -type => 'OK'); if ( $msgbox_unacceptable_domain_entered eq "ok" ) { clear_entry(); } } # end of if domain_name } # end of sub check_imput_entry #------------------------------------------------- sub domain_sub { # this is called from check_input_entry the $domain_name is passed to the sub # $domain_name was acceptable type, so check in whois my $domain_name = shift; my($domain_obj) = ""; clear_output(); # clear the output text box # first check if whois server is available $domain_obj = Net::Whois::Domain->new($domain_name) or fatal_error(); #or die "can't connect to whois server to get information on $domain_name: $!\n"; # server is available if ( $domain_obj->ok ) { # call methods on $domain_obj to get name, tag, address, etc. #print "The domain is called ", $domain_obj->domain, "\n"; $domain_output_text_box->insert('end', "\nThe domain is called ".$domain_obj->domain."\n"); #print "Its tag is ", $domain_obj->tag, "\n"; $domain_output_text_box->insert('end', "Its tag is ".$domain_obj->tag."\n"); #print "Mail for ", $domain_obj->name, " should be sent to:\n"; $domain_output_text_box->insert('end', "Mail for ".$domain_obj->name." should be sent to:\n"); #print map { "\t$_\n" } $domain_obj->address; $domain_output_text_box->insert('end', $domain_obj->address."\n"); #print "\t", $domain_obj->country, "\n"; $domain_output_text_box->insert('end', $domain_obj->country."\n"); my $contact_hash = $domain_obj->contacts; if ($contact_hash) { #print "Contacts:\n"; $domain_output_text_box->insert('end', "Contacts:\n"); foreach my $type (sort keys %$contact_hash) { #print " $type:\n"; $domain_output_text_box->insert('end', " ".$type.":\n"); foreach my $line (@{$contact_hash->{$type}}) { #print " $line\n"; $domain_output_text_box->insert('end', " ".$line."\n"); } } } else { #print "no contact information.\n"; $domain_output_text_box->insert('end', "no contact information\n"); } #print "Name Servers: \n"; $domain_output_text_box->insert('end', "Name Servers: \n"); #printf " %s (%s)$/", @$_ for @{$domain_obj->servers}; foreach (@{$domain_obj->servers}) { $domain_output_text_box->insert('end', " ".$$_[0]." (".$$_[1].")\n"); } #print "\n"; $domain_output_text_box->insert('end', "\n"); #print "Record created: ", $domain_obj->record_created, "\n"; $domain_output_text_box->insert('end', "Record created: ".$domain_obj->record_created."\n"); #print "Record updated: ", $domain_obj->record_updated, "\n"; $domain_output_text_box->insert('end', "Record updated: ".$domain_obj->record_updated."\n"); } else { my $msgbox_no_domain_found_text = "\n\n$domain_name not found\n\n"; my $msgbox_no_domain_found = $main->messageBox(-icon => 'warning', -message => "$msgbox_no_domain_found_text", -title => 'no domain found', -type => 'OK'); # warning message first time an unfound match, thereafter no message just the # not found message box #c:/perl/scripts/tk_whois_perl.pl # #Use of uninitialized value at C:/PERL/site/lib/Net/Whois.pm line 288 (#1) # # (W) An undefined value was used as if it were already defined. It was # interpreted as a "" or a 0, but maybe it was a mistake. To suppress this # warning assign an initial value to your variables. # #Use of uninitialized value at C:/PERL/site/lib/Net/Whois.pm line 289 (#1) #Use of uninitialized value at C:/PERL/site/lib/Net/Whois.pm line 294 (#1) #Use of uninitialized value at C:/PERL/site/lib/Net/Whois.pm line 297 (#1) # #fgsgsdgsdg.com not found #Note that all fields except ``name'' and ``tag'' may be undef because #``whois'' information is erratically filled in. #print "\n$domain_name not found\n\n"; } # end of if $domain_obj->ok } # end of domain_sub #------------------------------------------------- sub clear_entry { # clear the entry box # set the focus $domain_input_entry->delete(0, 'end'); $domain_input_entry->focus; } #------------------------------------------------- sub clear_output { # clear out the output text box $domain_output_text_box->delete('1.0','end'); } #------------------------------------------------- sub check_if_online { my $online_check; # check if already online by pinging dialup server my $host = "208.59.251.68"; my $p = Net::Ping->new() or die "can't create new ping object: $!\n"; if ( $p->ping($host) ) { $online_check = "Y"; } else { $online_check = "N"; } $p->close; return $online_check; } #------------------------------------------------- sub fatal_error { my $msgbox_unable_to_contact_text = "\n\ncan't contact server or server busy\n\$!\nexiting whois\n"; my $msgbox_unable_to_contact = $main->messageBox(-icon => 'error', -message => "$msgbox_unable_to_contact_text", -title => 'unable to contact server', -type => 'OK'); $main->destroy; exit; } #------------------------------------------------- ------------------------------------------------------------------ # original script that produces no warnings running in DOS window #!/perl -w # whois_perl.pl use diagnostics; use strict; use Net::Whois; use Net::Ping; my($domain_obj); # get input my $online_check = check_if_online(); if ( $online_check eq "N" ) { print "\n\nmust be online to use whois\n\n"; print "\nreturn to internet_perl menu to dialup\n\n"; exit; } else { print "\n\nenter domain name to search for: \n\n"; my $domain_name=; chomp($domain_name); if ( $domain_name eq "" ) { print "\n\nyou didn't enter anything\n\n"; print "return to internet_perl menu\n\n"; exit; } else { $domain_obj = Net::Whois::Domain->new($domain_name) or die "can't connect to whois server to get information on $domain_name: $!\n"; if ( $domain_obj->ok ) { # call methods on $domain_obj to get name, tag, address, etc. print "The domain is called ", $domain_obj->domain, "\n"; print "Its tag is ", $domain_obj->tag, "\n"; print "Mail for ", $domain_obj->name, " should be sent to:\n"; print map { "\t$_\n" } $domain_obj->address; print "\t", $domain_obj->country, "\n"; my $contact_hash = $domain_obj->contacts; if ($contact_hash) { print "Contacts:\n"; foreach my $type (sort keys %$contact_hash) { print " $type:\n"; foreach my $line (@{$contact_hash->{$type}}) { print " $line\n"; } } } else { print "no contact information.\n"; } print "Name Servers: \n"; printf " %s (%s)$/", @$_ for @{$domain_obj->servers}; print "\n"; print "Record created: ", $domain_obj->record_created, "\n"; print "Record updated: ", $domain_obj->record_updated, "\n"; } else { print "\n$domain_name not found\n\n"; } } } #################################################### sub check_if_online { my $online_check; # check if already online by pinging dialup server my $host = "208.59.251.68"; my $p = Net::Ping->new() or die "can't create new ping object: $!\n"; if ( $p->ping($host) ) { $online_check = "Y"; } else { $online_check = "N"; } $p->close; return $online_check; } ####################################################