Perl: END { }

Sometimes in coding I've found that you need to have code that runs on exit, regardless of why. In Python you can use atexit but in Perl it's as easy as defining an END code block:

END {
    # Do some clean up code
    close OUTPUT_FILE;
    output_close_message()
}

Cool it looks like there is a BEGIN method as well!

Leave A Reply
All content licensed under the Creative Commons License