[Date Prev][Date Next][Thread Prev][Thread Next] [Search] [Date Index] [Thread Index]

Re: [MacPerl] regarding Filehandle



In article <mac-perl.199811182304.AAA26062@iis.ee.ethz.ch>, Desiree Brewer
<dbrewer@mulryan-nash.com> wrote:

>I was working on the first chapter of the book. I really need to learn
>this for my job. I'm having some dificulty figuring out how to create a
><WORDSLIST>. It's really great, because I copied the whole program down
>(correctly). I ran it in perl, but it doesn't look in the wordslist like
>it's supposed to and find all the appropriate passwords. Instead it
>returns the "password incorrect answer and the only way to make it answer
>correctly is to give the default answer or to be the one person that
>doesn't have to give a password. I  checked my syntax and it's OKAY. I
>made a new script and called it wordlist and then saved it, but it can
>never find it. I work on a mac os8 system. and I was really hoping that
>you could tell me where in my MacPerl files the WORDSLIST is suppoussed
>to go and do I just write the individual passwords without any other code
>or do I do something else? I've included an example of the code I've
>written so far

For simplicity, just put your "wordslist" file in the same folder as the
Perl script file, which can be anywhere on your drive.

One problem I noticed:

>sub init_words {
>        open (WORDSLIST, "wordslist") || die "can't open wordslist: $!";
>        while ( defined ($name = <WORDSLIST>))  {
>                chomp ($name);
>                $word = <WORDSLIST>;
>                chomp $word;
>                $words {$name} = $word;
>                close (WORDSLIST) || die "couldn't close wordslist: $!";
>        }
>}

You are closing the file inside of you "while" loop here, which isn't what
you want. This would only read the first name and password pair, then
close the file.

I hope this gets you started.
-- 
__________________________________________________________________________

Jeff Clites                Online Editor           http://www.MacTech.com/
online@MacTech.com         MacTech Magazine
__________________________________________________________________________

***** Want to unsubscribe from this list?
***** Send mail with body "unsubscribe" to mac-perl-request@iis.ee.ethz.ch