#!/usr/bin/perl -w -T
#--------------- file test.pl ---------------  
package MyPackage;  
use strict;
use vars qw(@ISA);

use Net::Server::PreFork; 
# any personality will do  
@ISA = qw(Net::Server::PreFork);  
MyPackage->run(conf_file => "test.conf" );
exit;  

### over-ridden subs below  
sub process_request {

	my $self = shift;

	eval {      
		local $SIG{ALRM} = sub { die "Timed Out!\n" };
		my $timeout = 30; 
		# give the user 30 seconds to type a line      
		my $previous_alarm = alarm($timeout);
		while( <STDIN> ) {
			s/\r?\n$//;
			print "You said \"$_\"\r\n";
			alarm($timeout);
		}
		alarm($previous_alarm);
	};    

	if( $@=~/timed out/i ){
		print STDOUT "Timed Out.\r\n";
		return;
	}  
}  

1;  #--------------- file test.pl ---------------
