about summary refs log tree commit
diff options
context:
space:
mode:
authorSteve Hay <steve.m.hay@googlemail.com>2014-06-04 14:24:38 +0100
committerSteve Hay <steve.m.hay@googlemail.com>2014-06-04 14:24:38 +0100
commit247c8bd750d3c1e014363873a290f997e82c4a47 (patch)
tree217a5fb4c421fd4256a3b6ccb8cd706169837286
parentaf0e9fb706ab2c04ed3c02b1f2316ff7485d1ccb (diff)
downloadperl-libnet-247c8bd750d3c1e014363873a290f997e82c4a47.tar.gz
Make code Perl::Critic clean
-rw-r--r--Changes1
-rw-r--r--lib/Net/Cmd.pm20
-rw-r--r--lib/Net/Config.pm3
-rw-r--r--lib/Net/Domain.pm18
-rw-r--r--lib/Net/FTP.pm72
-rw-r--r--lib/Net/FTP/A.pm4
-rw-r--r--lib/Net/FTP/I.pm4
-rw-r--r--lib/Net/NNTP.pm28
-rw-r--r--lib/Net/Netrc.pm19
-rw-r--r--lib/Net/POP3.pm34
-rw-r--r--lib/Net/SMTP.pm17
-rw-r--r--lib/Net/Time.pm10
-rw-r--r--t/config.t10
-rw-r--r--t/datasend.t8
-rw-r--r--t/ftp.t8
-rw-r--r--t/hostname.t8
-rw-r--r--t/netrc.t16
-rw-r--r--t/nntp.t8
-rw-r--r--t/require.t8
-rw-r--r--t/smtp.t8
-rw-r--r--t/time.t8
21 files changed, 133 insertions, 179 deletions
diff --git a/Changes b/Changes
index 0b5ac33..83e1e2c 100644
--- a/Changes
+++ b/Changes
@@ -1,5 +1,6 @@
 libnet 1.28  -- TODO
 
+  * Make code Perl::Critic clean.
   * Move Net/*.pm into lib/Net/ sub-directory within distribution. This is the
     usual layout style these days.
   * Change Net::SMTP::auth() so that it now falls back to another supported AUTH
diff --git a/lib/Net/Cmd.pm b/lib/Net/Cmd.pm
index 48aea55..be395e7 100644
--- a/lib/Net/Cmd.pm
+++ b/lib/Net/Cmd.pm
@@ -78,7 +78,7 @@ sub toascii {
 
 
 sub _print_isa {
-  no strict qw(refs);
+  no strict 'refs'; ## no critic (TestingAndDebugging::ProhibitNoStrict)
 
   my $pkg = shift;
   my $cmd = $pkg;
@@ -271,7 +271,7 @@ sub getline {
   my $partial = defined(${*$cmd}{'net_cmd_partial'}) ? ${*$cmd}{'net_cmd_partial'} : "";
   my $fd      = fileno($cmd);
 
-  return undef
+  return
     unless defined $fd;
 
   my $rin = "";
@@ -289,7 +289,7 @@ sub getline {
         carp(ref($cmd) . ": Unexpected EOF on command channel")
           if $cmd->debug;
         $cmd->close;
-        return undef;
+        return;
       }
 
       substr($buf, 0, 0) = $partial;    ## prepend from last sysread
@@ -304,7 +304,7 @@ sub getline {
     else {
       my $msg = $select_ret ? "Error or Interrupted: $!" : "Timeout";
       carp("$cmd: $msg") if ($cmd->debug);
-      return undef;
+      return;
     }
   }
 
@@ -364,7 +364,7 @@ sub response {
     last unless ($more);
   }
 
-  return undef unless defined $code;
+  return unless defined $code;
   substr($code, 0, 1);
 }
 
@@ -375,7 +375,7 @@ sub read_until_dot {
   my $arr = [];
 
   while (1) {
-    my $str = $cmd->getline() or return undef;
+    my $str = $cmd->getline() or return;
 
     $cmd->debug_print(0, $str)
       if ($cmd->debug & 4);
@@ -457,14 +457,14 @@ sub datasend {
       my $w = syswrite($cmd, $line, $len, $offset);
       unless (defined($w)) {
         carp("$cmd: $!") if $cmd->debug;
-        return undef;
+        return;
       }
       $len -= $w;
       $offset += $w;
     }
     else {
       carp("$cmd: Timeout") if ($cmd->debug);
-      return undef;
+      return;
     }
   }
 
@@ -500,14 +500,14 @@ sub rawdatasend {
       my $w = syswrite($cmd, $line, $len, $offset);
       unless (defined($w)) {
         carp("$cmd: $!") if $cmd->debug;
-        return undef;
+        return;
       }
       $len -= $w;
       $offset += $w;
     }
     else {
       carp("$cmd: Timeout") if ($cmd->debug);
-      return undef;
+      return;
     }
   }
 
diff --git a/lib/Net/Config.pm b/lib/Net/Config.pm
index c0ed9a0..88d083b 100644
--- a/lib/Net/Config.pm
+++ b/lib/Net/Config.pm
@@ -41,6 +41,8 @@ our %NetConfig = (
 #
 # Try to get as much configuration info as possible from InternetConfig
 #
+{
+## no critic (BuiltinFunctions::ProhibitStringyEval)
 $^O eq 'MacOS' and eval <<TRY_INTERNET_CONFIG;
 use Mac::InternetConfig;
 
@@ -61,6 +63,7 @@ my %nc = (
 \@NetConfig{keys %nc} = values %nc;
 }
 TRY_INTERNET_CONFIG
+}
 
 my $file = __FILE__;
 my $ref;
diff --git a/lib/Net/Domain.pm b/lib/Net/Domain.pm
index f3d1772..c74f66b 100644
--- a/lib/Net/Domain.pm
+++ b/lib/Net/Domain.pm
@@ -64,12 +64,12 @@ sub _hostname {
       my $tmp = "\0" x 256;    ## preload scalar
       eval {
         package main;
-        require "syscall.ph";
+        require "syscall.ph"; ## no critic (Modules::RequireBarewordIncludes)
         defined(&main::SYS_gethostname);
         }
         || eval {
         package main;
-        require "sys/syscall.ph";
+        require "sys/syscall.ph"; ## no critic (Modules::RequireBarewordIncludes)
         defined(&main::SYS_gethostname);
         }
         and $host =
@@ -125,15 +125,14 @@ sub _hostdomain {
   # calls to gethostbyname, and therefore DNS lookups. This helps
   # those on dialup systems.
 
-  local *RES;
   local ($_);
 
-  if (open(RES, "/etc/resolv.conf")) {
-    while (<RES>) {
+  if (open(my $res, '<', "/etc/resolv.conf")) {
+    while (<$res>) {
       $domain = $1
         if (/\A\s*(?:domain|search)\s+(\S+)/);
     }
-    close(RES);
+    close($res);
 
     return $domain
       if (defined $domain);
@@ -152,11 +151,11 @@ sub _hostdomain {
       my $tmp = "\0" x 256;    ## preload scalar
       eval {
         package main;
-        require "syscall.ph";
+        require "syscall.ph"; ## no critic (Modules::RequireBarewordIncludes)
         }
         || eval {
         package main;
-        require "sys/syscall.ph";
+        require "sys/syscall.ph"; ## no critic (Modules::RequireBarewordIncludes)
         }
         and $dom =
         (syscall(&main::SYS_getdomainname, $tmp, 256) == 0)
@@ -191,8 +190,7 @@ sub _hostdomain {
     next unless @info;
 
     # look at real name & aliases
-    my $site;
-    foreach $site ($info[0], split(/ /, $info[1])) {
+    foreach my $site ($info[0], split(/ /, $info[1])) {
       if (rindex($site, ".") > 0) {
 
         # Extract domain from FQDN
diff --git a/lib/Net/FTP.pm b/lib/Net/FTP.pm
index 3a4af03..1d4e0eb 100644
--- a/lib/Net/FTP.pm
+++ b/lib/Net/FTP.pm
@@ -76,7 +76,7 @@ sub new {
     ? $arg{Timeout}
     : 120
     )
-    or return undef;
+    or return;
 
   ${*$ftp}{'net_ftp_host'}    = $host;                             # Remote hostname
   ${*$ftp}{'net_ftp_type'}    = 'A';                               # ASCII/binary/etc mode
@@ -219,10 +219,9 @@ sub size {
   }
   elsif ($ftp->supported("STAT")) {
     my @msg;
-    return undef
+    return
       unless $ftp->_STAT($file) && (@msg = $ftp->message) == 3;
-    my $line;
-    foreach $line (@msg) {
+    foreach my $line (@msg) {
       return (split(/\s+/, $line))[4]
         if $line =~ /^[-rwxSsTt]{10}/;
     }
@@ -396,7 +395,7 @@ sub type {
   return $oldval
     unless (defined $type);
 
-  return undef
+  return
     unless ($ftp->_TYPE($type, @_));
 
   ${*$ftp}{'net_ftp_type'} = join(" ", $type, @_);
@@ -413,7 +412,7 @@ sub alloc {
   return $oldval
     unless (defined $size);
 
-  return undef
+  return
     unless ($ftp->_ALLO($size, @_));
 
   ${*$ftp}{'net_ftp_allo'} = join(" ", $size, @_);
@@ -459,7 +458,7 @@ sub get {
   delete ${*$ftp}{'net_ftp_pasv'};
 
   $data = $ftp->retr($remote)
-    or return undef;
+    or return;
 
   if ($localfd) {
     $loc = $local;
@@ -470,7 +469,7 @@ sub get {
     unless (sysopen($loc, $local, O_CREAT | O_WRONLY | ($rest ? O_APPEND: O_TRUNC))) {
       carp "Cannot open Local file $local: $!\n";
       $data->abort;
-      return undef;
+      return;
     }
   }
 
@@ -478,7 +477,7 @@ sub get {
     carp "Cannot binmode Local file $local: $!\n";
     $data->abort;
     close($loc) unless $localfd;
-    return undef;
+    return;
   }
 
   $buf = '';
@@ -508,7 +507,7 @@ sub get {
       $data->abort;
       close($loc)
         unless $localfd;
-      return undef;
+      return;
     }
   }
 
@@ -517,14 +516,14 @@ sub get {
   unless ($localfd) {
     unless (close($loc)) {
       carp "Cannot close file $local (perhaps disk space) $!\n";
-      return undef;
+      return;
     }
   }
 
   unless ($data->close())    # implied $ftp->response
   {
     carp "Unable to close datastream";
-    return undef;
+    return;
   }
 
   return $local;
@@ -583,15 +582,14 @@ sub rmdir {
   # Get a list of all the files in the directory
   my @filelist = grep { !/^\.{1,2}$/ } $ftp->ls($dir);
 
-  return undef
+  return
     unless @filelist;    # failed, it is probably not a directory
 
   return $ftp->delete($dir)
     if @filelist == 1 and $dir eq $filelist[0];
 
   # Go thru and delete each file or the directory
-  my $file;
-  foreach $file (map { m,/, ? $_ : "$dir/$_" } @filelist) {
+  foreach my $file (map { m,/, ? $_ : "$dir/$_" } @filelist) {
     next                 # successfully deleted the file
       if $ftp->delete($file);
 
@@ -618,7 +616,7 @@ sub restart {
 
   ${*$ftp}{'net_ftp_rest'} = $where;
 
-  return undef;
+  return;
 }
 
 
@@ -628,7 +626,7 @@ sub mkdir {
   my ($ftp, $dir, $recurse) = @_;
 
   $ftp->_MKD($dir) || $recurse
-    or return undef;
+    or return;
 
   my $path = $dir;
 
@@ -724,20 +722,20 @@ sub _store_cmd {
 
     unless (sysopen($loc, $local, O_RDONLY)) {
       carp "Cannot open Local file $local: $!\n";
-      return undef;
+      return;
     }
   }
 
   if ($ftp->type eq 'I' && !binmode($loc)) {
     carp "Cannot binmode Local file $local: $!\n";
-    return undef;
+    return;
   }
 
   delete ${*$ftp}{'net_ftp_port'};
   delete ${*$ftp}{'net_ftp_pasv'};
 
   $sock = $ftp->_data_cmd($cmd, grep { defined } $remote)
-    or return undef;
+    or return;
 
   $remote = ($ftp->message =~ /\w+\s*:\s*(.*)/)[0]
     if 'STOU' eq uc $cmd;
@@ -769,7 +767,7 @@ sub _store_cmd {
       close($loc)
         unless $localfd;
       print $hashh "\n" if $hashh;
-      return undef;
+      return;
     }
   }
 
@@ -779,7 +777,7 @@ sub _store_cmd {
     unless $localfd;
 
   $sock->close()
-    or return undef;
+    or return;
 
   if ('STOU' eq uc $cmd and $ftp->message =~ m/unique\s+file\s*name\s*:\s*(.*)\)|"(.*)"/) {
     require File::Basename;
@@ -926,7 +924,7 @@ sub _dataconn {
   my $data = undef;
   my $pkg  = "Net::FTP::" . $ftp->type;
 
-  eval "require " . $pkg;
+  eval "require " . $pkg; ## no critic (BuiltinFunctions::ProhibitStringyEval)
 
   $pkg =~ s/ /_/g;
 
@@ -1004,7 +1002,7 @@ sub _data_cmd {
   my $where = delete ${*$ftp}{'net_ftp_rest'} || 0;
   my $arg;
 
-  for $arg (@_) {
+  for my $arg (@_) {
     croak("Bad argument '$arg'\n")
       if $arg =~ /[\r\n]/s;
   }
@@ -1015,14 +1013,14 @@ sub _data_cmd {
   {
     my $data = undef;
 
-    return undef unless defined $ftp->pasv;
-    $data = $ftp->_dataconn() or return undef;
+    return unless defined $ftp->pasv;
+    $data = $ftp->_dataconn() or return;
 
     if ($where and !$ftp->_REST($where)) {
       my ($status, $message) = ($ftp->status, $ftp->message);
       $ftp->abort;
       $ftp->set_status($status, $message);
-      return undef;
+      return;
     }
 
     $ftp->command($cmd, @_);
@@ -1033,7 +1031,7 @@ sub _data_cmd {
     }
     $data->_close;
 
-    return undef;
+    return;
   }
 
   $ok = $ftp->port
@@ -1043,12 +1041,12 @@ sub _data_cmd {
   $ok = $ftp->_REST($where)
     if $ok && $where;
 
-  return undef
+  return
     unless $ok;
 
   if ($cmd =~ /(STOR|APPE|STOU)/ and exists ${*$ftp}{net_ftp_allo}) {
     $ftp->_ALLO(delete ${*$ftp}{net_ftp_allo})
-      or return undef;
+      or return;
   }
 
   $ftp->command($cmd, @_);
@@ -1073,7 +1071,7 @@ sub _data_cmd {
 
   close(delete ${*$ftp}{'net_ftp_listen'});
 
-  return undef;
+  return;
 }
 
 ##
@@ -1135,19 +1133,19 @@ sub pasv_xfer {
     unless (defined $dfile);
 
   my $port = $sftp->pasv
-    or return undef;
+    or return;
 
   $dftp->port($port)
-    or return undef;
+    or return;
 
-  return undef
+  return
     unless ($unique ? $dftp->stou($dfile) : $dftp->stor($dfile));
 
   unless ($sftp->retr($sfile) && $sftp->response == CMD_INFO) {
     $sftp->retr($sfile);
     $dftp->abort;
     $dftp->response();
-    return undef;
+    return;
   }
 
   $dftp->pasv_wait($sftp);
@@ -1166,10 +1164,10 @@ sub pasv_wait {
   my $dres = $ftp->response();
   my $sres = $non_pasv->response();
 
-  return undef
+  return
     unless $dres == CMD_OK && $sres == CMD_OK;
 
-  return undef
+  return
     unless $ftp->ok() && $non_pasv->ok();
 
   return $1
diff --git a/lib/Net/FTP/A.pm b/lib/Net/FTP/A.pm
index 6940bc2..4c99019 100644
--- a/lib/Net/FTP/A.pm
+++ b/lib/Net/FTP/A.pm
@@ -46,7 +46,7 @@ sub read {
           : undef;
       }
       else {
-        return undef
+        return
           unless defined $n;
 
         ${*$data}{'net_ftp_eof'} = 1;
@@ -104,7 +104,7 @@ sub write {
 
     $off += $wrote;
     $wrote = syswrite($data, substr($tmp, $off), $len > $blksize ? $blksize : $len);
-    return undef
+    return
       unless defined($wrote);
     $len -= $wrote;
   }
diff --git a/lib/Net/FTP/I.pm b/lib/Net/FTP/I.pm
index 0e9e5ff..0145ed2 100644
--- a/lib/Net/FTP/I.pm
+++ b/lib/Net/FTP/I.pm
@@ -34,7 +34,7 @@ sub read {
     $blksize = $size if $size > $blksize;
 
     unless ($n = sysread($data, ${*$data}, $blksize, length ${*$data})) {
-      return undef unless defined $n;
+      return unless defined $n;
       ${*$data}{'net_ftp_eof'} = 1;
     }
   }
@@ -73,7 +73,7 @@ sub write {
       or croak "Timeout";
 
     my $n = syswrite($data, $buf, $sent > $blksize ? $blksize : $sent, $off);
-    return undef unless defined($n);
+    return unless defined($n);
     $sent -= $n;
     $off += $n;
   }
diff --git a/lib/Net/NNTP.pm b/lib/Net/NNTP.pm
index ee023f4..b10de12 100644
--- a/lib/Net/NNTP.pm
+++ b/lib/Net/NNTP.pm
@@ -42,20 +42,18 @@ sub new {
     unless @{$hosts};
 
   my %connect = ( Proto => 'tcp');
-  my $o;
-  foreach $o (qw(LocalAddr Timeout)) {
+  foreach my $o (qw(LocalAddr Timeout)) {
     $connect{$o} = $arg{$o} if exists $arg{$o};
   }
   $connect{Timeout} = 120 unless defined $connect{Timeout};
   $connect{PeerPort} = $arg{Port} || 'nntp(119)';
-  my $h;
-  foreach $h (@{$hosts}) {
+  foreach my $h (@{$hosts}) {
     $connect{PeerAddr} = $h;
     $obj = $type->SUPER::new(%connect)
       and last;
   }
 
-  return undef
+  return
     unless defined $obj;
 
   ${*$obj}{'net_nntp_host'} = $connect{PeerAddr};
@@ -65,7 +63,7 @@ sub new {
 
   unless ($obj->response() == CMD_OK) {
     $obj->close;
-    return undef;
+    return;
   }
 
   my $c = $obj->code;
@@ -405,6 +403,7 @@ sub distribution_patterns {
   my $arr;
   local $_;
 
+  ## no critic (ControlStructures::ProhibitMutatingListFunctions)
   $nntp->_LIST('DISTRIB.PATS')
     && ($arr = $nntp->read_until_dot)
     ? [grep { /^\d/ && (chomp, $_ = [split /:/]) } @$arr]
@@ -513,7 +512,7 @@ sub xpath {
   @_ == 2 or croak 'usage: $nntp->xpath( MESSAGE-ID )';
   my ($nntp, $mid) = @_;
 
-  return undef
+  return
     unless $nntp->_XPATH($mid);
 
   my $m;
@@ -592,12 +591,11 @@ sub _timestr {
 sub _grouplist {
   my $nntp = shift;
   my $arr  = $nntp->read_until_dot
-    or return undef;
+    or return;
 
   my $hash = {};
-  my $ln;
 
-  foreach $ln (@$arr) {
+  foreach my $ln (@$arr) {
     my @a = split(/[\s\n]+/, $ln);
     $hash->{$a[0]} = [@a[1, 2, 3]];
   }
@@ -609,12 +607,11 @@ sub _grouplist {
 sub _fieldlist {
   my $nntp = shift;
   my $arr  = $nntp->read_until_dot
-    or return undef;
+    or return;
 
   my $hash = {};
-  my $ln;
 
-  foreach $ln (@$arr) {
+  foreach my $ln (@$arr) {
     my @a = split(/[\t\n]/, $ln);
     my $m = shift @a;
     $hash->{$m} = [@a];
@@ -638,12 +635,11 @@ sub _articlelist {
 sub _description {
   my $nntp = shift;
   my $arr  = $nntp->read_until_dot
-    or return undef;
+    or return;
 
   my $hash = {};
-  my $ln;
 
-  foreach $ln (@$arr) {
+  foreach my $ln (@$arr) {
     chomp($ln);
 
     $hash->{$1} = $ln
diff --git a/lib/Net/Netrc.pm b/lib/Net/Netrc.pm
index 826d386..2888bc0 100644
--- a/lib/Net/Netrc.pm
+++ b/lib/Net/Netrc.pm
@@ -21,7 +21,7 @@ our $TESTING;
 my %netrc = ();
 
 sub _readrc {
-  my $host = shift;
+  my($class, $host) = @_;
   my ($home, $file);
 
   if ($^O eq "MacOS") {
@@ -60,7 +60,7 @@ sub _readrc {
     my @stat = stat($file);
 
     if (@stat) {
-      if ($stat[2] & 077) {
+      if ($stat[2] & 077) { ## no critic (ValuesAndExpressions::ProhibitLeadingZeros)
         carp "Bad permissions: $file";
         return;
       }
@@ -94,7 +94,7 @@ sub _readrc {
       while (@tok) {
         if ($tok[0] eq "default") {
           shift(@tok);
-          $mach = bless {};
+          $mach = bless {}, $class;
           $netrc{default} = [$mach];
 
           next TOKEN;
@@ -107,7 +107,7 @@ sub _readrc {
 
         if ($tok eq "machine") {
           my $host = shift @tok;
-          $mach = bless {machine => $host};
+          $mach = bless {machine => $host}, $class;
 
           $netrc{$host} = []
             unless exists($netrc{$host});
@@ -136,9 +136,9 @@ sub _readrc {
 
 
 sub lookup {
-  my ($pkg, $mach, $login) = @_;
+  my ($class, $mach, $login) = @_;
 
-  _readrc()
+  $class->_readrc()
     unless exists $netrc{default};
 
   $mach ||= 'default';
@@ -147,12 +147,11 @@ sub lookup {
 
   if (exists $netrc{$mach}) {
     if (defined $login) {
-      my $m;
-      foreach $m (@{$netrc{$mach}}) {
+      foreach my $m (@{$netrc{$mach}}) {
         return $m
           if (exists $m->{login} && $m->{login} eq $login);
       }
-      return undef;
+      return;
     }
     return $netrc{$mach}->[0];
   }
@@ -160,7 +159,7 @@ sub lookup {
   return $netrc{default}->[0]
     if defined $netrc{default};
 
-  return undef;
+  return;
 }
 
 
diff --git a/lib/Net/POP3.pm b/lib/Net/POP3.pm
index 186ef81..d10d940 100644
--- a/lib/Net/POP3.pm
+++ b/lib/Net/POP3.pm
@@ -66,8 +66,7 @@ sub new {
 
   $arg{Timeout} = 120 if ! defined $arg{Timeout};
 
-  my $h;
-  foreach $h (@{$hosts}) {
+  foreach my $h (@{$hosts}) {
     $obj = $type->SUPER::new(
       PeerAddr => ($host = $h),
       PeerPort => $arg{Port} || 'pop3(110)',
@@ -78,7 +77,7 @@ sub new {
       and last;
   }
 
-  return undef
+  return
     unless defined $obj;
 
   ${*$obj}{'net_pop3_arg'} = \%arg;
@@ -95,7 +94,7 @@ sub new {
 
   unless ($obj->response() == CMD_OK) {
     $obj->close();
-    return undef;
+    return;
   }
 
   ${*$obj}{'net_pop3_banner'} = $obj->message;
@@ -155,10 +154,10 @@ sub apop {
   }
   else {
     carp "You need to install Digest::MD5 or MD5 to use the APOP command";
-    return undef;
+    return;
   }
 
-  return undef
+  return
     unless ($banner = (${*$me}{'net_pop3_banner'} =~ /(<.*>)/)[0]);
 
   if (@_ <= 2) {
@@ -167,7 +166,7 @@ sub apop {
 
   $md->add($banner, $pass);
 
-  return undef
+  return
     unless ($me->_APOP($user, $md->hexdigest));
 
   $me->_get_mailbox_count();
@@ -185,7 +184,7 @@ sub pass {
 
   my ($me, $pass) = @_;
 
-  return undef
+  return
     unless ($me->_PASS($pass));
 
   $me->_get_mailbox_count();
@@ -212,7 +211,7 @@ sub reset {
 sub last {
   @_ == 1 or croak 'usage: $obj->last()';
 
-  return undef
+  return
     unless $_[0]->_LAST && $_[0]->message =~ /(\d+)/;
 
   return $1;
@@ -223,7 +222,7 @@ sub top {
   @_ == 2 || @_ == 3 or croak 'usage: $pop3->top( MSGNUM [, NUMLINES ])';
   my $me = shift;
 
-  return undef
+  return
     unless $me->_TOP($_[0], $_[1] || 0);
 
   $me->read_until_dot;
@@ -245,7 +244,7 @@ sub list {
   @_ == 1 || @_ == 2 or croak 'usage: $pop3->list( [ MSGNUM ] )';
   my $me = shift;
 
-  return undef
+  return
     unless $me->_LIST(@_);
 
   if (@_) {
@@ -254,7 +253,7 @@ sub list {
   }
 
   my $info = $me->read_until_dot
-    or return undef;
+    or return;
 
   my %hash = map { (/(\d+)\D+(\d+)/) } @$info;
 
@@ -266,7 +265,7 @@ sub get {
   @_ == 2 or @_ == 3 or croak 'usage: $pop3->get( MSGNUM [, FH ])';
   my $me = shift;
 
-  return undef
+  return
     unless $me->_RETR(shift);
 
   $me->read_until_dot(@_);
@@ -296,16 +295,15 @@ sub uidl {
   my $uidl;
 
   $me->_UIDL(@_)
-    or return undef;
+    or return;
   if (@_) {
     $uidl = ($me->message =~ /\d+\s+([\041-\176]+)/)[0];
   }
   else {
     my $ref = $me->read_until_dot
-      or return undef;
-    my $ln;
+      or return;
     $uidl = {};
-    foreach $ln (@$ref) {
+    foreach my $ln (@$ref) {
       my ($msg, $uid) = $ln =~ /^\s*(\d+)\s+([\041-\176]+)/;
       $uidl->{$msg} = $uid;
     }
@@ -397,7 +395,7 @@ sub DESTROY {
 
 sub response {
   my $cmd  = shift;
-  my $str  = $cmd->getline() or return undef;
+  my $str  = $cmd->getline() or return;
   my $code = "500";
 
   $cmd->debug_print(0, $str)
diff --git a/lib/Net/SMTP.pm b/lib/Net/SMTP.pm
index 315a52b..c51c00d 100644
--- a/lib/Net/SMTP.pm
+++ b/lib/Net/SMTP.pm
@@ -67,8 +67,7 @@ sub new {
 
   $arg{Timeout} = 120 if ! defined $arg{Timeout};
 
-  my $h;
-  foreach $h (@{ref($hosts) ? $hosts : [$hosts]}) {
+  foreach my $h (@{ref($hosts) ? $hosts : [$hosts]}) {
     $obj = $type->SUPER::new(
       PeerAddr => ($host = $h),
       PeerPort => $arg{Port} || 'smtp(25)',
@@ -80,7 +79,7 @@ sub new {
       and last;
   }
 
-  return undef
+  return
     unless defined $obj;
 
   ${*$obj}{'net_smtp_arg'} = \%arg;
@@ -97,7 +96,7 @@ sub new {
     my $err = ref($obj) . ": " . $obj->code . " " . $obj->message;
     $obj->close();
     $@ = $err;
-    return undef;
+    return;
   }
 
   ${*$obj}{'net_smtp_exact_addr'} = $arg{ExactAddresses};
@@ -110,7 +109,7 @@ sub new {
     my $err = ref($obj) . ": " . $obj->code . " " . $obj->message;
     $obj->close();
     $@ = $err;
-    return undef;
+    return;
   }
 
   $obj;
@@ -231,8 +230,7 @@ sub hello {
 
   if ($ok) {
     my $h = ${*$me}{'net_smtp_esmtp'} = {};
-    my $ln;
-    foreach $ln (@msg) {
+    foreach my $ln (@msg) {
       $h->{uc $1} = $2
         if $ln =~ /([-\w]+)\b[= \t]*([^\n]*)/;
     }
@@ -242,7 +240,7 @@ sub hello {
       if $ok = $me->_HELO($domain);
   }
 
-  return undef unless $ok;
+  return unless $ok;
   ${*$me}{net_smtp_hello_domain} = $domain;
 
   $msg[0] =~ /\A\s*(\S+)/;
@@ -467,8 +465,7 @@ sub recipient {
   }
 
   my @ok;
-  my $addr;
-  foreach $addr (@_) {
+  foreach my $addr (@_) {
     if ($smtp->_RCPT("TO:" . _addr($smtp, $addr) . $opts)) {
       push(@ok, $addr) if $skip_bad;
     }
diff --git a/lib/Net/Time.pm b/lib/Net/Time.pm
index 7b59805..41e26a8 100644
--- a/lib/Net/Time.pm
+++ b/lib/Net/Time.pm
@@ -35,9 +35,9 @@ sub _socket {
 
   my $me;
 
-  foreach $host (@$hosts) {
+  foreach my $addr (@$hosts) {
     $me = IO::Socket::INET->new(
-      PeerAddr => $host,
+      PeerAddr => $addr,
       PeerPort => $port,
       Proto    => $proto
       )
@@ -59,11 +59,11 @@ sub _socket {
 
 
 sub inet_time {
-  my $s      = _socket('time', 37, @_) || return undef;
+  my $s      = _socket('time', 37, @_) || return;
   my $buf    = '';
   my $offset = 0 | 0;
 
-  return undef
+  return
     unless defined $s->recv($buf, length(pack("N", 0)));
 
   # unpack, we | 0 to ensure we have an unsigned
@@ -89,7 +89,7 @@ sub inet_time {
 
 
 sub inet_daytime {
-  my $s   = _socket('daytime', 13, @_) || return undef;
+  my $s   = _socket('daytime', 13, @_) || return;
   my $buf = '';
 
   defined($s->recv($buf, 1024))
diff --git a/t/config.t b/t/config.t
index be508e3..d686ab1 100644
--- a/t/config.t
+++ b/t/config.t
@@ -6,16 +6,12 @@ use strict;
 use warnings;
 
 BEGIN {
-    if ($ENV{PERL_CORE}) {
-        chdir 't' if -d 't';
-        @INC = '../lib';
-    }
-    if (!eval "require Socket") {
+    if (!eval { require Socket; 1 }) {
         print "1..0 # no Socket\n"; exit 0;
     }
     undef *{Socket::inet_aton};
     undef *{Socket::inet_ntoa};
-    if (ord('A') == 193 && !eval "require Convert::EBCDIC") {
+    if (ord('A') == 193 && !eval { require Convert::EBCDIC; 1 }) {
         print "1..0 # EBCDIC but no Convert::EBCDIC\n"; exit 0;
     }
     $INC{'Socket.pm'} = 1;
@@ -25,7 +21,7 @@ package Socket;
 
 sub import {
         my $pkg = caller();
-        no strict 'refs';
+        no strict 'refs'; ## no critic (TestingAndDebugging::ProhibitNoStrict)
         *{ $pkg . '::inet_aton' } = \&inet_aton;
         *{ $pkg . '::inet_ntoa' } = \&inet_ntoa;
 }
diff --git a/t/datasend.t b/t/datasend.t
index 1c4a0c7..cdbdc29 100644
--- a/t/datasend.t
+++ b/t/datasend.t
@@ -6,14 +6,10 @@ use strict;
 use warnings;
 
 BEGIN {
-    if ($ENV{PERL_CORE}) {
-        chdir 't' if -d 't';
-        @INC = '../lib';
-    }
-    if (!eval "require Socket") {
+    if (!eval { require Socket; 1 }) {
         print "1..0 # no Socket\n"; exit 0;
     }
-    if (ord('A') == 193 && !eval "require Convert::EBCDIC") {
+    if (ord('A') == 193 && !eval { require Convert::EBCDIC; 1 }) {
         print "1..0 # EBCDIC but no Convert::EBCDIC\n"; exit 0;
     }
 }
diff --git a/t/ftp.t b/t/ftp.t
index 7ee4623..288cdbc 100644
--- a/t/ftp.t
+++ b/t/ftp.t
@@ -6,14 +6,10 @@ use strict;
 use warnings;
 
 BEGIN {
-    unless (-d 'blib') {
-        chdir 't' if -d 't';
-        @INC = '../lib';
-    }
-    if (!eval "require Socket") {
+    if (!eval { require Socket; 1 }) {
         print "1..0 # Skip: no Socket module\n"; exit 0;
     }
-    if (ord('A') == 193 && !eval "require Convert::EBCDIC") {
+    if (ord('A') == 193 && !eval { require Convert::EBCDIC; 1 }) {
         print "1..0 # Skip: EBCDIC but no Convert::EBCDIC\n"; exit 0;
     }
 }
diff --git a/t/hostname.t b/t/hostname.t
index e831b2d..25f1cda 100644
--- a/t/hostname.t
+++ b/t/hostname.t
@@ -6,14 +6,10 @@ use strict;
 use warnings;
 
 BEGIN {
-    unless (-d 'blib') {
-        chdir 't' if -d 't';
-        @INC = '../lib';
-    }
-    if (!eval "require Socket") {
+    if (!eval { require Socket; 1 }) {
         print "1..0 # no Socket\n"; exit 0;
     }
-    if (ord('A') == 193 && !eval "require Convert::EBCDIC") {
+    if (ord('A') == 193 && !eval { require Convert::EBCDIC; 1 }) {
         print "1..0 # EBCDIC but no Convert::EBCDIC\n"; exit 0;
     }
 }
diff --git a/t/netrc.t b/t/netrc.t
index 6281ef1..1149bb8 100644
--- a/t/netrc.t
+++ b/t/netrc.t
@@ -6,14 +6,10 @@ use strict;
 use warnings;
 
 BEGIN {
-    if ($ENV{PERL_CORE}) {
-        chdir 't' if -d 't';
-        @INC = '../lib';
-    }
-    if (!eval "require Socket") {
+    if (!eval { require Socket; 1 }) {
         print "1..0 # no Socket\n"; exit 0;
     }
-    if (ord('A') == 193 && !eval "require Convert::EBCDIC") {
+    if (ord('A') == 193 && !eval { require Convert::EBCDIC; 1 }) {
         print "1..0 # EBCDIC but no Convert::EBCDIC\n"; exit 0;
     }
 }
@@ -59,8 +55,8 @@ SKIP: {
         };
 
         # add write access for group/other
-        $stat[2] = 077;
-        ok( !defined(Net::Netrc::_readrc()),
+        $stat[2] = 077; ## no critic (ValuesAndExpressions::ProhibitLeadingZeros)
+        ok( !defined(Net::Netrc->_readrc()),
                 '_readrc() should not read world-writable file' );
         ok( scalar($warn =~ /^Bad permissions:/),
                 '... and should warn about it' );
@@ -69,7 +65,7 @@ SKIP: {
         $stat[2] = 0;
 
         if ($<) {
-          ok( !defined(Net::Netrc::_readrc()),
+          ok( !defined(Net::Netrc->_readrc()),
               '_readrc() should not read file owned by someone else' );
           ok( scalar($warn =~ /^Not owner:/),
                 '... and should warn about it' );
@@ -96,7 +92,7 @@ macdef
 LINES
 
 # having set several lines and the uid, this should succeed
-is( Net::Netrc::_readrc(), 1, '_readrc() should succeed now' );
+is( Net::Netrc->_readrc(), 1, '_readrc() should succeed now' );
 
 # on 'foo', the login is 'nigol'
 is( Net::Netrc->lookup('foo')->{login}, 'nigol',
diff --git a/t/nntp.t b/t/nntp.t
index a084045..303aac4 100644
--- a/t/nntp.t
+++ b/t/nntp.t
@@ -6,14 +6,10 @@ use strict;
 use warnings;
 
 BEGIN {
-    unless (-d 'blib') {
-        chdir 't' if -d 't';
-        @INC = '../lib';
-    }
-    if (!eval "require Socket") {
+    if (!eval { require Socket; 1 }) {
         print "1..0 # no Socket\n"; exit 0;
     }
-    if (ord('A') == 193 && !eval "require Convert::EBCDIC") {
+    if (ord('A') == 193 && !eval { require Convert::EBCDIC; 1 }) {
         print "1..0 # EBCDIC but no Convert::EBCDIC\n"; exit 0;
     }
 }
diff --git a/t/require.t b/t/require.t
index d7f839d..a48951a 100644
--- a/t/require.t
+++ b/t/require.t
@@ -6,14 +6,10 @@ use strict;
 use warnings;
 
 BEGIN {
-    unless (-d 'blib') {
-        chdir 't' if -d 't';
-        @INC = '../lib';
-    }
-    if (!eval "require Socket") {
+    if (!eval { require Socket; 1 }) {
         print "1..0 # no Socket\n"; exit 0;
     }
-    if (ord('A') == 193 && !eval "require Convert::EBCDIC") {
+    if (ord('A') == 193 && !eval { require Convert::EBCDIC; 1 }) {
         print "1..0 # EBCDIC but no Convert::EBCDIC\n"; exit 0;
     }
 }
diff --git a/t/smtp.t b/t/smtp.t
index 5bd1966..634390f 100644
--- a/t/smtp.t
+++ b/t/smtp.t
@@ -6,14 +6,10 @@ use strict;
 use warnings;
 
 BEGIN {
-    unless (-d 'blib') {
-        chdir 't' if -d 't';
-        @INC = '../lib';
-    }
-    if (!eval "require Socket") {
+    if (!eval { require Socket; 1 }) {
         print "1..0 # no Socket\n"; exit 0;
     }
-    if (ord('A') == 193 && !eval "require Convert::EBCDIC") {
+    if (ord('A') == 193 && eval { require Convert::EBCDIC; 1 }) {
         print "1..0 # EBCDIC but no Convert::EBCDIC\n"; exit 0;
     }
 }
diff --git a/t/time.t b/t/time.t
index 07712fb..43b0e0e 100644
--- a/t/time.t
+++ b/t/time.t
@@ -6,14 +6,10 @@ use strict;
 use warnings;
 
 BEGIN {
-    if ($ENV{PERL_CORE}) {
-        chdir 't' if -d 't';
-        @INC = '../lib';
-    }
-    if (!eval "require Socket") {
+    if (!eval { require Socket; 1 }) {
         print "1..0 # no Socket\n"; exit 0;
     }
-    if (ord('A') == 193 && !eval "require Convert::EBCDIC") {
+    if (ord('A') == 193 && !eval { require Convert::EBCDIC; 1 }) {
         print "1..0 # EBCDIC but no Convert::EBCDIC\n"; exit 0;
     }
     $INC{'IO/Socket.pm'} = 1;