#!/usr/bin/env perl use strict; use warnings; END { # "the very last thing a script does" } END { # Call destructors and other cleanup here } # ... rest of script here ...