It can't this stupid program to terminate properly.
Here it is:
# /usr/bin/perl -w
init_words();
print "What is your name ?";
$name =<STDIN>;
$name =~ s/\W.*//;
$name =~ tr/A-Z/a-z/;
chomp($name);
print "Hello $name\n";
print" What is the secret password ?->";
$guess=<STDIN>;
chomp($guess);
$pw=$words { $name };
print " pw= $pw name= $name guess=$guess";
while ($guess ne $pw )
{
print "Wrong, try again.\n";
print "What is the password?->";
$guess=<STDIN>;
chomp($guess) ;
}
sub init_words
{
open(WORDLIST,"wordlist") || die "can't open wordlist";
while($name =<WORDLIST> )
{
chomp($name);
$word=<WORDLIST>;
chomp($word);
$words{$name}=$word;
}
close(WORDLIST);
}
The WORDLIST file is
fred -name
camel -pwl
barney -name
llama -pw
linus
tux
It ask you for your name then your password. If it doesn't match it goes into
a loop until it gets it right. The problem is when you enter the correct
password for the correct name it goes into the loop endlessly. I can't figure
out why. This problem arose when I created the init_words sub routine.
before I used the array
%words = qw(fred camel
barney llama
linus tux
);
it worked fine. Now things are fubared. Why ?
_______________________________________________
Redhat-list mailing list
[EMAIL PROTECTED]
https://listman.redhat.com/mailman/listinfo/redhat-list