Using eval.
eval {
local $SIG{ALRM} = sub {die "something is wrong"};
alarm 30;
do_something...
alarm 0;
};
if ($@) {
handle_for_the_errors();
}
-----Original Message-----
>From: Kelly Jones <[EMAIL PROTECTED]>
>Sent: Dec 25, 2006 9:45 AM
>To: [email protected], [EMAIL PROTECTED]
>Subject: system() command with a time limit
>
>I want to use system() (or `command`) to run an external command from
>my Perl script. However, if the external command takes more than 30
>seconds (for example) to run, I want to kill it, and move on with the
>rest of my Perl script. How do I do this?
>
>--
>We're just a Bunch Of Regular Guys, a collective group that's trying
>to understand and assimilate technology. We feel that resistance to
>new ideas and technology is unwise and ultimately futile.
>
>--
>To unsubscribe, e-mail: [EMAIL PROTECTED]
>For additional commands, e-mail: [EMAIL PROTECTED]
><http://learn.perl.org/> <http://learn.perl.org/first-response>
>
>
--
Books below translated by me to Chinese.
Practical mod_perl: http://home.earthlink.net/~pangj/mod_perl/
Squid the Definitive Guide: http://home.earthlink.net/~pangj/squid/
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>