use strict; use warnings; $SIG{INT}=\&handler; sub handler { while(1) { print "Do you want to really quit....."; chomp(my $a=); if($a =~ /y/) { exit(0); } elsif($a =~ /n/) { return; } else { next; } } } while(1) { }