in reply to Calling a custom sub on failure

I would probably do something like this:

if (!open($HANDLE, ">>filename.log")) { # call a sub-routine }
mike