#!/usr/bin/perl -w init_word(); print "What is your name? "; $name = ; chomp $name; if ($name =~ /^aaron\b/i) { print "Hello, Aaron. How good of you to join me.\n"; } else { print "Hello $name.\n"; print "What is the secret word? "; $guess = ; chomp $guess; while (!good_word($name, $guess)) { print "Wrong try again. What is the secret word? "; $guess = ; chomp $guess; } } sub good_word { my($somename, $someguess) = @_; $somename =~ s/\W.*//; $somename =~ tr/A-Z/a-z/; if($somename eq "aaron") { return 1; } elsif ( ($words{$somename} || "groucho") eq $someguess) { return 1; } else { return 0; } } sub init_word { open (WORDLIST, "wordlist"); while($name = ){ chomp($name); $word = ; chomp($word); $words{$name} = $word; } close(WORDLIST); }