#!/usr/bin/perl use warnings; use strict; $SIG{ALRM} = sub { die "timeout!!! alarm\n" }; alarm(5); #start the timer print "waiting for alarm..hit any key..."; ; print "waiting for another input line"; ; print "past the IO stuff, normal exit\n"; __END__ should see this if no key at all is hit waiting for alarm..hit any key...timeout!!! alarm