[Techtalk] On Perl

kansas_kennedy at phreaker.net kansas_kennedy at phreaker.net
Thu Jul 25 00:52:53 EST 2002


I am afraid that I couldn't quite follow this program off Learning Perl. 
The parts not quite clear to me are:
$i = 0;
$correct = "maybe"; {
while ($correct eq "maybe")
{
if ($words[$i] eq $guess){
$correct = "yes";
}
elsif ($i < 2) {
$i = $i + 1;

Anyone would like to help?

----------------------the whole program-----------------------

#!/usr/bin/perl
@words = qw (llama camel alpaca);
print "what is your name\n";
$name = <stdin>;
chomp $name;
if ($name eq "tan") {
print "hey man\n";
}
else
{
print "hi, $name\n";
print "enter the password\n";
$guess = <stdin>;
chomp $guess;
$i = 0;
$correct = "maybe"; {
while ($correct eq "maybe")
{
if ($words[$i] eq $guess){
$correct = "yes";
}
elsif ($i < 2) {
$i = $i + 1;
}
else
{
print "wrong. try again\n";
$guess = <stdin>;
chomp $guess;
$i = 0;
}
}
}}
#EOF.





More information about the Techtalk mailing list