Hello listers, I am using "Learning Perl on Win 32 Systems" and am having a problem(a pretty hasic problem) with one of the programs in the book. I cammot get the variables $somename and $someguess to value. I have checked and de-bugged this thing amd can't figure out what is wrong. Maybe I have been looking at it too long. Thanks for any words of wisdom. Eric #!/usr/bin/perl init_words(); print "What is your name? \n"; chomp ($name = <>P; if ($name =~ /^erik\b/i) { print "Hello, $name! How good og you to be here.\n"; } else { print "Hello, $name!\n"; print "What is the secret word? \n"; chomp ($guess = <>); while (! good_word($name,$guess)) { print "Wrong, try again. What is the secret word? \n"; chomp ($guess = <>); } } ## subroutines from here down sub init_words { open (WORDSLIST, "wordslist.dat") || die "can't open wordslist:$!"; if (-M WORDSLIST > 7.0) { die "Sorry, the wordslist is older than seven days."; } while (defined ($name = <WORDSLIST>)) { chomp ($name); $word = <WORDSLIST>; chomp ($word); $words{$name} = $word; } close (WORDSLIST); }
sub good_word { my ($somename, $someguess) = @_; $somename =~ s/\w.*//; $somename =~ tr/A-Z/a-z/; if ($somename eq "erik") { return 1; } elsif (($words{$somename} || "groucho") eq $someguess) { return 1; } else { return 0; } } This is the file I am reading in: fred camel barney gecko betty alpaca wilma alpaca ***********End of e-mail*********** _______________________________________________ Perl-Win32-Users mailing list [EMAIL PROTECTED] To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs