title: How to timeout on a Perl function call
body: <p>How can I put a time limit (apply timeout handling) on a Perl subroutine call?  I want to cancel the subroutine if it runs for too long.  The subroutine may call out into C libraries (e.g., a C-based database driver) which means special handling is needed.  Also, SIGALRM may already ben in use so we can't use directly alarm().</p>