please help HELP
---------- Forwarded message ----------
Date: Mon, 20 Aug 2001 05:04:31 -0400 (EDT)
From: webmaster <[EMAIL PROTECTED]>
To: Paul Johnson <[EMAIL PROTECTED]>
Cc: Gary Stainburn <[EMAIL PROTECTED]>,
jim-ryan <[EMAIL PROTECTED]>, [EMAIL PROTECTED]
I have a little problem, it has to do with an exampole from the randal
schwartz perl book, this is the script and after the script is the error
msg I am gettin can some of you please lwt let me know what is it, cheers
#!/usr/bin/perl
%words=("fred","camel","barney","llama","betty","oyster","wilma","oyster");
print "what is your name ";
$name=<STDIN>;
chop($name);
if ($name eq "randal")
{
print "hello randall";
}
else
{
print "hello $name";
$secretword = words{$name};
if ($secretword eq "")
{
$secretword="groucho";
}
print "what is the sw? ";
$guess=<STDIN>;
chop($guess);
while ($guess ne $secretword)
{
print "no es try agaIN ";
$guess=<STDIN>;
chop($guess);
}
}
Can't locate object method "words" via package "d" at test-2-3.pl line
13, <STDIN> chunk 1.
what in the hell does that mean? can some of you please let me know
that, cheers
one more thingg if I am supposue to look for a secret word in a separrate
file, and the files name is suppouse to be WORDLIST I put the file in the
same place as the script but anyway the script is not using it... I am
talking about randals example page 20... from wich I am also sendig the
script source code...cheer
#!/usr/bin/perl
&init_words;
print "what is your name ";
$name=<STDIN>;
chop($name);
if ($name=~ /^randal\b/i)
{
print "hello randal \n";
}
else
{
print "hello $original_name";
print "what is the secret word ";
$guess=<STDIN>;
chop($guess);
while (! &good_word($name,$$guess))
{
print "wrogn, try again ";
$guess=<STDIN>;
chop($guess);
}
}
#subtns
sub init_words
{
open (WORDLIST, "wordlist");
if (-M WORDLIST >7)
{
die "sorry";
}
while ($name=<WORDLIST>)
{
{
chop($name);
$word=<WORDLIST>;
chop($word);
$words{$name}=$word;
}
close (WORDLIST);
}
sub good_word
{
local($somename,$someguess)=@_;
$somename=~ s/\W.*//;
$somename=~ tr/A-Z/a-z/;
if ($somename eq "randal")
{
1;
}
elsif(($words{$somename}||"groucho") eq $someguess)
{
1;
}
else
{
0;
}
}
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]