trying to modernize Perl so that dependency can be dropped
authorNicholas Bamber <nicholas@periapt.co.uk>
Sat, 12 Jan 2019 09:23:59 +0000 (09:23 +0000)
committerAndres Salomon <dilinger@debian.org>
Sat, 12 Jan 2019 09:23:59 +0000 (09:23 +0000)
Forwarded: not-needed
Last-Update: 2012-05-05

Gbp-Pq: Name obsolete

scripts/identd.perl5
scripts/sort_res.perl5

index 6662fac71d4b3e461ab37c70248ee52a17e23987..cd583e022da55cf7486cfe13346af259c094f525 100755 (executable)
 #
 # Kapil Chowksey <kchowksey@hss.hns.com>
 ###################################################################
-
+use strict;
 use Socket;
-require 'getopts.pl';
+use Getopt::Long;
 
 # Set path to lsof.
 
-if (($LSOF = &isexec("../lsof")) eq "") {      # Try .. first
+my $LSOF;
+if (($LSOF = &isexec("/usr/bin/lsof")) eq "") {        # Try .. first
     if (($LSOF = &isexec("lsof")) eq "") {     # Then try . and $PATH
        print "can't execute $LSOF\n"; exit 1
     }
@@ -34,18 +35,16 @@ if (($LSOF = &isexec("../lsof")) eq "") {   # Try .. first
 close(STDERR);
 open(STDERR, ">/dev/null");
 
-$Timeout = "120";
+my $Timeout = "120";
 
-&Getopts('t:');
-if ($opt_t) {
-    $Timeout = $opt_t;
-}
+GetOptions('timeout=i'=>\$Timeout);
 
-($port, $iaddr) = sockaddr_in(getpeername(STDIN));
-$peer_addr = inet_ntoa($iaddr);
+my ($port, $iaddr) = sockaddr_in(getpeername(STDIN));
+my $peer_addr = inet_ntoa($iaddr);
+my $query;
 
 # read ident-query from socket (STDIN) with a timeout.
-$timeout = int($Timeout);
+my $timeout = int($Timeout);
 eval {
     local $SIG{ALRM} = sub { die "alarm\n" };
     alarm $timeout;
@@ -61,8 +60,8 @@ if ($@) {
 # remove all white-spaces from query
 $query =~ s/\s//g;
 
-$serv_port = "";
-$cli_port = "";
+my $serv_port = "";
+my $cli_port = "";
 ($serv_port,$cli_port) = split(/,/,$query);
 
 if ($serv_port =~ /^[0-9]+$/) {
@@ -87,8 +86,8 @@ if ($cli_port =~ /^[0-9]+$/) {
 
 open(LSOFP,"$LSOF -nPDi -T -FLn -iTCP@".$peer_addr.":".$cli_port."|");
 
-$user = "UNKNOWN";
-while ($a_line = <LSOFP>) {
+my $user = "UNKNOWN";
+while (my $a_line = <LSOFP>) {
     # extract user name.
     if ($a_line =~ /^L.*/) {
         ($user) = ($a_line =~ /^L(.*)/);
index cf11950ade32fce64f3e17edc0d973b515a76be5..b3459a3c881623a6eb3fc834b534e490cd4b29ce 100755 (executable)
@@ -33,7 +33,6 @@
 #      -removing unuseful line number arg.
 #      -display global size
 
-require 'getopts.pl';
 my @args = @_;
 
 # Set path to lsof.