C:\PERL\bin>perl -le"$SIG{INT}=sub{print 'cleanup';exit 0}; while(1){sleep 1}; END{print 'goodbye'}" # here I hit Control-C cleanup goodbye