[Date Prev][Date Next][Thread Prev][Thread Next] [Search] [Date Index] [Thread Index]

[MacPerl] Compilation error with "elsif" command



Hello MacPerl users:

I am a beginning MacPerl user, and I am working through "Learning
Perl", by Schwartz and Christiansen.

I am getting a compile error when I try to run the following script,
which is on page 9 of "Learning Perl".

Is there any known difficulty with the "elsif" command.

I appreciate your help.

Diana Dubel

#1/usr/bin/perl -w
@words = qw(camel llama alpaca);
print "What is your name? ";
$name = <STDIN>;
chomp ($name);
if ($name eq "Diana") {
     print "Hello, Diana!  How good of you to be here!\n";
} else {
     print "Hello, $name!\n";         # ordinary greeting
     print "What is the secret word? ";
     $guess = <STDIN>;
     chomp ($guess);
     $i = 0; # try this word first
     $correct = "maybe";              # is the guess correct or not?
     while ($correct eq "maybe") {    # keep checking till we know
          if ($words[$i] eq $guess) } # right?
              $correct = "yes";       # yes!
          } elsif ($i < 2) {          # more words to look at?
               $i = $i + 1;           # look at the next word next time
          } else {                    # no more words, must be bad
               print "Wrong, try again. What is the secret word?";
               $guess = <STDIN>;
               chomp ($guess);
               $i = 0;           # start checking at the first word
again
          }
     } # end of while not correct
} #end of "not Diana"




==
Diana L. Dubel    dldubel@earthlink.net    diana_lynn@yahoo.com

:-)

:-)
_________________________________________________________
DO YOU YAHOO!?
Get your free @yahoo.com address at http://mail.yahoo.com


***** Want to unsubscribe from this list?
***** Send mail with body "unsubscribe" to mac-perl-request@iis.ee.ethz.ch