#!C:\Perl64\bin init_words(); print "What is your name Mr. \n"; $name = ; chomp ($name); if ($name =~ /^randal\b/i){ print "Hello, Randal, How are you doing \n"; } else{ print "Hello, $name!\n"; print "Tell the secret word\n"; $guess = ; chomp ($guess); while (!good_word ($name,$guess)){ print "Wrong, please try again\n"; $guess = ; chomp ($guess); } } sub init_words { open (WORDSLIST, "wordslist.txt") || die "can't open wordslist: $!"; $k = 1; $a = 0; $b = 0; while (defined ($name = )) { if ($k % 2 == 0){ chomp ($name); @words1[$a] = $name; ++$k; ++$a; } else{ chomp ($name); @words2[$b] = $name; ++$k; ++$b; } } close (WORDSLIST) || die "couldn't close wordlist: $!"; } sub good_word { my ($somename, $someguess) = @_; $somename =~ s/\W.*//; $somename =~ tr/A-Z/a-z/; if ($somename eq "randal"){ return 1;} else { #$n = 0; $t = scalar @words1; $u = scalar @words2; print "the words2 array is @words2"; for ($d = 0; $d < $u; $d++) { print "currently name in array is @words2[$d]\n"; print "The value of somename is $somename \n"; if ("@words2[$d]" eq "$somename"){ print "test"; return 1;} } #print "The final value of d is $d"; #print " The final value of array is @words1[$d]"; #if ("groucho" eq $someguess){ #return 1;} #else{ #while ($n < $t){ #if (@words1[$n] eq $someguess) { #return 1;} #else { ++$n}; } } # } #}