in reply to Calling a custom sub on failure
if (!open($HANDLE, ">>filename.log")) { # call a sub-routine } [download]