http://www.perlmonks.org?node_id=1021799


in reply to Re: coming out of perl script after 10 min.
in thread coming out of perl script after 10 min.

#!/usr/bin/perl eval { local %SIG; $SIG{ALRM}= sub{ die "timeout reached, after 20 seconds!\n"; }; alarm 20; print "sleeping for 60 seconds\n"; #sleep 60; # This is where to put your code, between the alarms $x=<stdin>; alarm 0; }; alarm 0; if($@) { print "Error: $@\n"; } exit(0);
Here we should enter some input, but my requirement is if the input is not enetered in 20 sec, it should come out of the program(Exit the program).

Replies are listed 'Best First'.
Re^3: coming out of perl script after 10 min.
by moritz (Cardinal) on Mar 05, 2013 at 17:13 UTC
    but my requirement is if the input is not enetered in 20 sec, it should come out of the program(Exit the program).

    And that's what the program does (as far as I can tell; but hard to tell, since it is formatted so badly here). Which is why I wonder what your actual question is.