> -----Original Message-----
> From: Chris and Madonna Stalnaker [mailto:[EMAIL PROTECTED]]
> Sent: Saturday, November 17, 2001 1:55 AM
> To: [EMAIL PROTECTED]
> Subject: stupid question
> 
> 
> I have to start somewhere,
> 
> This works:
> 
>       print "Enter your name: ";
>       $text = <STDIN>;
>       print "\nHello $text\n";
>       print "Please enter your password: ";
>       $password = <STDIN>;
> 
>       if ($password == 21)
>       {
>               print"Correct\n";
>       } 
>       else 
>       {
>               print "wrong\n";
>       }
> 
> This doesn't:
> 
>       print "Enter your name: ";
>       $text = <STDIN>;
>       print "\nHello $text\n";
>       print "Please enter your password: ";
>       $password eq <STDIN>;
> 
>       if ($password eq qwert)
>       {
>               print"Correct\n";
>       } 
>       else 
>       {
>               print "wrong\n";
>       }
> 
> Why?
> 
> if anyone replies Thank you, (flames expected!!)

You've gotten some pointers, but can I add my $0.02 for future reference
and for the benefit of other posters?

1. Please avoid the phrase "Doesn't work". Your script is syntactically
legal and runs without producing any error messages, so I we could claim
that it does indeed "work".

Instead *define* what "doesn't work" means. The best way, IMO, is to 
specify A) what the expected behavior is, and B) what the observed behavior 
is. So in this case you might say:

   "I expect to enter a user name and password, and then have the
   program print 'Correct' if I enter enter the password qwert.
   The program does prompt for user name and password, but always
   prints 'wrong', even if I enter the correct password, qwert.

2. Put the following lines at the top of *every* script unless you 
absolutely know what you're doing and have good reason to do otherwise:

   #!/usr/bin/perl -w
   use strict;

Doing so in this case would have highlighted the very things that make
your script "not work".

3. If you get warning messages that you don't understand, run your 
script like this:

   perl -Mdiagnostics myscript.pl

This will give you expanded descriptions to go along with warnings.

Good luck!

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

Reply via email to