tells the program that if the filehandle LOG fails to initialize to print the error message
May I ask you where you get this idea?
If you want to know whether the open failed, you need to check the return code of the open function which you used to open the file. If it is false (i.e. undef, 0 or ''), the error message can be found in "$!".