How easy is it, in Perl, to have a function which gets called on SIGINT (when you press ctrl+C or just do a normal kill) and does some tidying up -- i.e. writes its results so far to a database and unlinks its pidfile -- before exiting?