On 8/6/07, Ken Foskey <[EMAIL PROTECTED]> wrote:

>From a design perspective how safe is it to use DB2 updates
> in an END block?

Pretty darn safe.

But that's like asking how safe it is to cross the street, isn't it?
Usually it's pretty safe, if you take some basic precautions and
expect it to fail spectacularly once in a while.

END blocks will run if your perl binary is still alive to run them. If
you run completely out of memory, catch an unexpected serious signal,
or have some other major malfunction, perl itself is dead and nothing
can bring it back. If you divide by zero, use invalid syntax in a
pattern match, or call an undefined subroutine, perl itself catches
your error, and thus it can still run your END blocks.

But in that way, END blocks are no different than any other control
structure. If perl can keep running your program to the end, and right
through the ENDs, it will.

So, you may as well think of an END block as a control structure
that's handy for its own special need (i.e. postponing execution as
long as possible) but no more or less reliable than the rest of Perl.

Of course, since by definition the END blocks are the last acts of a
successful execution, they're the most likely part to have not
succeeded after a major crash. But when a major crash happens, you're
likely to know you need to do some cleanup. And maybe also, to teach
somebody not to use 'kill -9' to shut down your program. :-)

Good luck with it!

--Tom Phoenix
Stonehenge Perl Training

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/


Reply via email to