walkingthecow has asked for the wisdom of the Perl Monks concerning the following question:
#!/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; } } }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Have $SIG{INT} ask if user wants to quit
by lakshmananindia (Chaplain) on Mar 11, 2009 at 07:31 UTC | |
by Anonymous Monk on Mar 11, 2009 at 08:02 UTC | |
by afoken (Chancellor) on Mar 11, 2009 at 15:25 UTC | |
|
Re: Have $SIG{INT} ask if user wants to quit
by ig (Vicar) on Mar 11, 2009 at 08:40 UTC | |
by walkingthecow (Friar) on Mar 11, 2009 at 17:10 UTC | |
by ig (Vicar) on Mar 12, 2009 at 14:40 UTC | |
|
Re: Have $SIG{INT} ask if user wants to quit
by repellent (Priest) on Mar 11, 2009 at 17:03 UTC |