I usually display what the defaults are at first and then use a  carriage 
return to signify that is what I want.

        You can test like:

        if ( $question eq '' ) {
         # place the default value into $question
       }

        I usually use a infinite loop and when values are correct, then last out of 
the loop:

        while ( 1 ) {
           print "default value";
           print "Enter value:";
           chomp(my $question = <STDIN>);
           if ( $question eq '' ) {
            # put default value in
          } 
         #
           # do what is necessary to validate $question
         last if ( $question is valid );
         print "Expecting  ..........\n";
           print "Please enter correct value.\n";
       }
      You might put under a larger while 1  and give the user a last chance that all 
the input is correct.

Wags ;)
-----Original Message-----
From: Michael Gargiullo [mailto:[EMAIL PROTECTED]]
Sent: Tuesday, April 09, 2002 14:45
To: Beginners
Subject: default value


While asking a few questions to run a script.  How can I give a default
answer?

Right now I'm asking my question like so:

print "File to use:";
chomp(my $question = <STDIN>);

-Mike


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to