One thing to realize is that
open(WORDLIST, "wordlist")
opens a file called wordlist, not WORDLIST.
You might want to check in to getting the Learning Perl book...it is a
better beginner's book than is the Perl Cookbook.

Tanton
-----Original Message-----
From: webmaster
To: perl
Sent: 8/20/2001 4:48 AM
Subject: thanks and keep helping!!!

well thanks for the help... but ... well need osme some more ofo your 
expertise... sorry but I am a new new newest in this perl thing

well following this randal swartz book, the example where the scritpt 
should opne an external file and check for a secretword... the external 
file is supposuse to be WORDLIST, and I assume it must be on the same 
path as the script... but something is not working so agaon I am sendig 
you the script by the way I saved a WORDLIST file in the same path as
the 
script is, so well hope you can help me this time as well... cheers

#!/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;
      }
    
}  
  

so the WORDLIST file is supposuse acording to randals book to be like
this:

fred
camel
wilma
oyster


well hope not to be boring you with thsi easy things.. but I am stuck.. 
and really would like to learn perl , cheers

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to