in reply to Re: Have $SIG{INT} ask if user wants to quit
in thread Have $SIG{INT} ask if user wants to quit
# define signal handler to catch contol-c $SIG{'INT'} = 'catch_int'; sub catch_int { my $ans; system("clear"); while ($ans !~ /[Nn]/) { print "Do you want to exit [y or n]? "; chomp($ans=<STDIN>); if ($ans =~ /[Yy]/) { exit(0); } } }
|
---|
Replies are listed 'Best First'. | |
---|---|
Re^3: Have $SIG{INT} ask if user wants to quit
by afoken (Chancellor) on Mar 11, 2009 at 15:25 UTC |