. . $runset{CHECK} = &AskQuestion("CHECK - Enter the check mode you want", my @checkmode = qw/flat cell hier comp/, $conf{CHECK}); . . $runset{CNAMES} = &AskQuestion("CNAMES - Do you want the run Case Sensitive", my @CS = qw/yes no/, $conf{CNAMES}); . . # Subroutine - AskQuestion # This will take a simple text for an answer and given a predetermined # array of answers will only accept one of the choices # # Obviously this returns a valid answer # sub AskQuestion (*\@;$){ my $prompt = shift; my $conf = pop; my @answers = @_; my $response; while ( ! $response ) { if ( ! $conf ) { print "$prompt [$_[0]]: "; $response = ; chomp $response; if ( $response eq "" ) { $response = $answers[0]; } if ( $response eq "?") { $response = ""; print " Valid answers are: \n"; print " @answers\n"; } } else { $response = $conf; } my $match; for ( my $i = 0; $i < @answers ; $i++ ){ if ( $response eq $answers[$i] ){ $match = "true"; return $response; } } if ( ! $match ){ $response = ""; $conf = ""} } }