#!/usr/bin/perl -w use strict; $SIG{INT} = \&catch_int; print "eat tacos for sustanence\n"; chomp(my $ans=<STDIN>); print "eat ham for sustanence\n"; chomp($ans=<STDIN>); sub catch_int { while (1) { print "Do you really want to quit? "; chomp(my $ans=<STDIN>); if ($ans =~ /[Yy]/) { exit(0); } elsif ($ans =~ /[Nn]/) { print "Resuming...\n"; last; } else { next; } } }
In reply to Have $SIG{INT} ask if user wants to quit by walkingthecow
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |