Beefy Boxes and Bandwidth Generously Provided by pair Networks
laziness, impatience, and hubris

Re: Random numbers and substitution

by ig (Vicar)
on May 31, 2011 at 09:07 UTC ( #907422=note: print w/replies, xml ) Need Help??

in reply to Random numbers and substitution

I haven't tried running your program, but I have a few suggestions for you to think about:

At the beginning of your program you open high_score.dat, then each time through your loop you read until end of file. So, the first time through the loop you read all the lines in the file, stopping when you reach end of file. What do you think happens the second time through the loop? When you start the second iteration of the loop, where do you start reading the file?

In your loop, after having read all the lines in the file, if the user guesses the correct name, you try to read more lines from the file. What do you think happens when you try to read a line from the file after having read all the way to the end of the file?

If you find the name of the user in the file, you change the score in $line. That's data in memory. What do you think you have to do to get that string from the scalar variable in memory to the file?

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://907422]
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others musing on the Monastery: (5)
As of 2017-11-22 01:46 GMT
Find Nodes?
    Voting Booth?
    In order to be able to say "I know Perl", you must have:

    Results (314 votes). Check out past polls.