SIG{INT}=sub{exit}; END { open LOGFILE, ">filename"; print LOGFILE '...everything figured out up to now '; close LOGFILE; }