Skip to content

Commit

Permalink
whois: add strict (#537)
Browse files Browse the repository at this point in the history
* I didn't notice that strict was not declared; when adding it a declaration for $line was also missing
* While here, prefer error string from IO::Socket over $! if connect fails (same change proposed for bin/mail)

perl whois -h 127.0.0.1 good.juan.com
127.0.0.1: IO::Socket::INET: connect: Connection refused
  • Loading branch information
mknos committed Apr 5, 2024
1 parent 5da850a commit 5f652dc
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions bin/whois
Expand Up @@ -20,6 +20,8 @@ License:
# Added a -6 switch for 6BONE (whois.6bone.net)
# Added a -g switch for .gov (whois.nic.gov)

use strict;

use Getopt::Std qw(getopts);
use IO::Socket;

Expand Down Expand Up @@ -54,11 +56,11 @@ sub whois {
Proto => 'tcp',
);
unless ($sock) {
warn "failed to connect: '$host': $!";
warn "$host: $IO::Socket::errstr\n";
exit EX_FAILURE;
}
print {$sock} "$domain\r\n";
while ($line = <$sock>) {
while (my $line = <$sock>) {
print $line;
}
close $sock;
Expand Down

0 comments on commit 5f652dc

Please sign in to comment.