in reply to Interactive Test
But, if having to press enter is acceptable, here's one method without using that module:
print "Do you want to run live tests (y/n)? "; my $answer = <STDIN>; # beware of trailing newlines if ($answer =~ /^n/i) { $foo = 0 } elsif ($answer =~ /^y/i { $foo = 1 } else { $foo = $default_foo } # default
Or, you could repeat question with a goto LABEL or by wrapping it in a loop and only breaking out when an answer is acceptable.
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Interactive Test
by ait (Hermit) on Sep 17, 2010 at 21:28 UTC |