in reply to Calling a custom sub on failure

You can just replace die with the name of the sub you want to run. You can put practically any command you want after the ||. There is nothing intrinsically special about the open||die pairing, it's just a common convention used to handle errors.

sub dontdie() { print "I didn't die\n"; } open(LOK, ">>C:\\Perl\\RTEOlock\\check\\RTEOlock.log") || dontdie();