Beefy Boxes and Bandwidth Generously Provided by pair Networks
No such thing as a small change
 
PerlMonks  

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?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others cooling their heels in the Monastery: (4)
As of 2016-12-10 23:09 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    On a regular basis, I'm most likely to spy upon:













    Results (165 votes). Check out past polls.