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:

    # Do some clean up code
    close OUTPUT_FILE;

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

Leave A Reply
All content licensed under the Creative Commons License