Beefy Boxes and Bandwidth Generously Provided by pair Networks
Your skill will accomplish
what the force of many cannot

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 the rats come out to play...

How do I use this? | Other CB clients
Other Users?
Others romping around the Monastery: (5)
As of 2018-02-22 01:22 GMT
Find Nodes?
    Voting Booth?
    When it is dark outside I am happiest to see ...

    Results (288 votes). Check out past polls.