in reply to Monitor Perl script within the same script?
The perl Cookbook has a recipe on using alarm to solve your problem. See 16.22 if you have the book.
Here is the code it uses$SIG{ALRM} = sub { die "timeout" }; eval { alarm(1200); # 20 minutes # long-time operations here alarm(0); }; if ($@) { if ($@ =~ /timeout/) { #timed out, do what you will here } else { die; # propagate the unexpected exception } }
|
|---|