in reply to Re: CGI::Carp use of BEGIN block to log errors (newbie question)
in thread CGI::Carp use of BEGIN block to log errors (newbie question)

To add to arturo's response, BEGIN blocks are processed in the order in which they're encountered during compilation. Not a problem if you only have one BEGIN block, but since you're acquiring an external resource (opening a file), you might need to pay attention to the order of multiple blocks.

Also, consider adding

END { close(LOG); }
END blocks are queued up and are executed in reverse (LIFO) order.