#!/usr/bin/perl use warnings; use strict; my %words = ( Sarah => 'cat', Bob => 'dog', Ronald => 'apple', Eric => 'banana' ); print "What is your name?"; chomp (my $name = ); if ($name eq "Jerry") { print "Hi, Jerry! Have a good day!\n"; } else { print "Hello, $name!\n"; #normal greeting my $secretword = $words{$name}; #get the secret word print "Guess the secret word.\n"; chomp (my $guess = ); while ($guess ne $secretword) { print "I'm sorry. That is not the correct word. Please try again.\nWhat is the secret word?"; chomp ($guess = ); } }