#!/usr/bin/perl -w $SIG{'INT'} = 'catch_int'; sub catch_int { my $int_ans; system("\n"); while ($int_ans !~ /[Nn]/) { print "Do you want to exit [y or n]? "; $int_ans=; if ($int_ans =~ /[Yy]/) { die "\nCaught SIGINT -- Program stopped by user\n"; } } } print "Please enter a choice: "; chomp(my $choice=); if ($choice =~ /[A-Z]+/i) { for (my $i = 0; $i < 10000; $i++) { print "Good choice!\n"; } }