!#/usr/bin/perl %words = qw(Sarah cat Bob dog Ronald apple Eric banana); print "What is your name?"; $name = <STDIN>; chomp ($name); if ($name eq "Jerry") { print "Hi, Jerry! Have a good day!\n";} else {print "Hello, $name!\n"; #normal greeting $secretword = $words{$name}; #get the secret word print "Guess the secret word.\n"; $guess = <STDIN>; chomp ($guess); while ($guess ne $secretword) { print "I'm sorry. That is not the correct word. Please try again. + What is the secret word?"; $guess = <STDIN>; chomp ($guess); } }
In reply to Creating a Hash Syntax Error by ms238
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |