cat foo.pl #!/usr/bin/perl use strict; use warnings; sub DESTROY { print "Called main::DESTROY()\n"; } END { print "END called\n" } # $SIG{INT} = sub { print "SIGINT received\n"; exit }; my $x = bless []; 1 while 1; $ perl foo.pl ^C $ perl -i.orig -pe 's/^#// if $. > 2' foo.pl perl foo.pl ^CSIGINT received Called main::DESTROY() END called