On Mon, Jan 26, 2004 at 11:33:07AM -0800, Henri Asseily wrote: > > my $alarm = 0; > eval { > local $SIG{ALRM} = sub { $alarm=1 }; > alarm(3); > $dbh = DBI->connect( ... ); > alarm(0); > }; > alarm(0); > > > is there really a need to alarm(0) outside the eval?
Yes. > Basically, if the > eval fails, doesn't the alarm(3) automatically get disabled due to it > being in the eval block? No. The $SIG{ALRM} gets undone because of the local(), but the alarm() doesn't. > And if we do need to have the alarm(0) both in and out of the eval > block, are there any unforseen consequences to setting alarm(0) a > couple of times in a row? No. Tim