diff -ruN nagiosplug-save/contrib/check_pop3.pl nagiosplug/contrib/check_pop3.pl
--- nagiosplug-save/contrib/check_pop3.pl	2004-03-03 04:24:35.000000000 +0000
+++ nagiosplug/contrib/check_pop3.pl	2004-03-27 22:56:15.000000000 +0000
@@ -1,4 +1,4 @@
-#!/usr/bin/perl
+#!/usr/bin/perl -wT
 # ------------------------------------------------------------------------------
 # File Name:    check_pop3.pl
 # Author:    Richard Mayhew - South Africa
@@ -34,39 +34,42 @@
 require 5.004;
 
 # --------------------------------------------------------------------[ Uses ]--
-use Socket;
 use strict;
+use lib utils.pm ;
+use Plugin;
+use Plugin::Parameter qw(:DEFAULT :standard $u_opt $P_opt $p_opt);
+
+use Socket;
+
+use vars qw($PROGNAME $remotehost $username $password $remoteport $opt_t);
 
+use utils qw(%ERRORS);
 # --------------------------------------------------------------[ Enviroment ]--
 $ENV{PATH} = "/bin";
 $ENV{BASH_ENV} = "";
 $|=1;
 # ------------------------------------------------------------------[ Global ]--
-my $TIMEOUT = 60;
-
-# -------------------------------------------------------------------[ usage ]--
-sub usage
-{
-	print "Minimum arguments not supplied!\n";
-	print "\n";
-	print "Perl Check POP3 plugin for Nagios\n";
-	print "Copyright (c) 2000 Richard Mayhew\n";
-	print "\n";
-	print "Usage: check_pop3.pl <host> <username> <password> [port]\n";
-	print "\n";
-	print "<port> = Port that the pop3 daemon is running on <host>. Defaults to 110.\n";
-	exit -1;
-
-}
+$H_opt->binding(\$remotehost);
+$u_opt->binding(\$username);
+$u_opt->optional("no");
+$P_opt->binding(\$password);
+$P_opt->flags([ 'P', 'password' ]);
+$P_opt->optional("no");
+$p_opt->binding(\$remoteport);
+$p_opt->default(110);
+$p_opt->description("Port that the pop3 daemon is running on");
+my $plugin = new Plugin(-revision => '$Revision: 1.2 $',
+			-copyright => "2000 Richard Mayhew, 2004 Howard Wilkinson <howard\@cohtech.com>",
+			-shortcomment => "Perl Check POP3 plugin for Nagios",
+			-parameterlists => [ [ $H_opt, $u_opt, $P_opt, $p_opt, $t_opt ], $h_opts, $V_opts ]);
 
 # --------------------------------------------------------------[ bindRemote ]--
 sub bindRemote
 {
-	my ($in_remotehost, $in_remoteport, $in_hostname) = @_;
-	my $proto;
+	my ($in_remotehost, $in_remoteport, $in_hostname, $proto) = @_;
 	my $sockaddr;
 	my $this;
-	my $thisaddr;
+	my $thisaddr = INADDR_ANY;
 	my $that;
 	my ($name, $aliases,$type,$len,$thataddr) = gethostbyname($in_remotehost);
 
@@ -84,35 +87,29 @@
 MAIN:
 {
 	my $hostname;
-	my $remotehost = shift || &usage;
-	my $username = shift || &usage;
-	my $password = shift || &usage;
-	my $remoteport = shift || 110;
-
-	# Just in case of problems, let's not hang Nagios
-	$SIG{'ALRM'} = sub {
-		print "Something is Taking a Long Time, Increase Your TIMEOUT (Currently Set At $TIMEOUT Seconds)\n";
-		exit -1;
-	};
-	
-	alarm($TIMEOUT);
+
+	$plugin->init();
+
+	$plugin->start_timeout($opt_t, "Something is Taking a Long Time, Increase Your TIMEOUT (Currently Set At $opt_t Seconds)");
 
 	chop($hostname = `hostname`);
 	my ($name, $alias, $proto) = getprotobyname('tcp');
-	my $ClientSocket = &bindRemote($remotehost,$remoteport,$hostname);
+	my $ClientSocket = &bindRemote($remotehost,$remoteport,$hostname,$proto);
 	
-
-	&err("no welcome banner\n") unless $_ = <ClientSocket>;
+	$_ = <ClientSocket>;
+	&err("no welcome banner\n") unless (defined $_ && $_);
 	&err("bad welcome banner: " . $_) unless $_ =~ /^\+OK/;
 
 	print ClientSocket "USER $username\r\n";
 
-	&err("no response to USER command\n") unless $_ = <ClientSocket>;
+	$_ = <ClientSocket>;
+	&err("no response to USER command\n") unless (defined $_ && $_);
 	&err("bad response to USER: " . $_) unless $_ =~ /^\+OK/;
 
 	print ClientSocket "PASS $password\r\n";
 
-	&err("no response to PASS command\n") unless $_ = <ClientSocket>;
+	$_ = <ClientSocket>;
+	&err("no response to PASS command\n") unless (defined $_ && $_);
 	&err("bad response to PASS: " . $_) unless $_ =~ /^\+OK/;
 
 	print ClientSocket "LIST\r\n";
@@ -125,17 +122,20 @@
 		$msgs = $1 if /^(\d+)\s+/;
 		last if /^\./;
 	}
+
 	&message("$msgs\n") unless $bad;
+
 	&err("missing +OK to LIST command\n");
 }
 
 sub message 
 {
 	my $msg = shift;
-	alarm(0);
 	print ClientSocket "QUIT\r\n";
-	print "POP3 OK - Total Messages On Server: $msg";
-	exit 0;
+	close ClientSocket;
+	$plugin->stop_timeout();
+	print "$PROGNAME OK - Total Messages On Server: $msg";
+	exit $ERRORS{'OK'};
 }
 
 sub err
@@ -143,6 +143,6 @@
 	my $msg = shift;
 	alarm(0);
 	print ClientSocket "QUIT\r\n";
-	print "POP3 Error: $msg";
-	exit 2;
+	print "$PROGNAME UNKNOWN: $msg";
+	exit $ERRORS{'UNKNOWN'};
 }
