On Wednesday, May 29, 2002, at 08:31 , Tor Hildrum wrote:
[..]
>> Just another question. How can I get a user input from the console in 
>> perl?
>> I'm just playing with the DBI Module and want to ask for a select 
>> statement,
>> which I can enter in the console. Executing the statment works already 
>> fine
>> *gg*.
>
> Do you mean like:
> print "Select what database to open:\n";
> chomp(my $db = <STDIN>);

For this I normally have a function of the form

        sub AskTheInfestationUnit {
                my ($msg ) = @_;
                my $answer ;

                print $msg ;    # you want to let them format it
                chomp(my $answer = <STDIN>);

                $answer;

        } # end AskTheInfestationUnit

hence everytime I want the hairless apes to answer you will
just see lines like:

        my $the_hairless_ape_said = AskTheInfestationUnit($msg);

        unless($the_hairless_ape_said =~ /$TheCorrectAnswer/) {
                hitHairlessApe();       # requires Wired::Seat
                $the_hairless_ape_said = AskTheInfestationUnit($msg);

        }

# note - if you need multiple lines of input you can wrap
# AskTheInfestationUnit($msg) in something that parses for
# an EONFHA { end of noise from hairless ape }

>
> Or % perlscript.pl database user
> Where you can access them trough $ARGV[0] and $ARGV[1]
>
> Tor

as for reading the command lines - yes, we all start there,
but the original author really will want to get on to

        perldoc Getopt::Standard

and
        perldoc Getopt::Long

sooner or later...

ciao
drieux

---


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

Reply via email to