/usr/src/perl/pod/perlfaq8/How_do_I_timeout_a_slow_event_.pod

How do I timeout a slow event?

Use the alarm function, probably in conjunction with a signal handler, as documented Signals and chapter 6 of the Camel. You may instead use the more flexible Sys::AlarmCall module available from CPAN.