Perl Programming/Keywords/alarm

The alarm keyword
alarm delivers a SIGALRM to this process after SECONDS wallclock seconds have passed. If SECONDS is omitted, contents of $_ are used. Some machines, however, may divert from the wallclock seconds by ±1 s.

This call starts one and only one timer; each new call disables the previous timer like a call with 0 would also do. From Perl 5.8.0 on, the timer with a better granularity is supplied by ualarm.

Instead of using <tt>alarm</tt>, it is possible to use Perl's four-argument version of <tt>select</tt> with the first three arguments undefined. Another way is to use <tt>syscall</tt> to access <tt>setitimer(2)</tt>, if supported.

Beware of intermixing <tt>alarm</tt> and <tt>sleep</tt> calls, as <tt>sleep</tt> may be internally implemented on the system with <tt>alarm</tt>ǃ