Beefy Boxes and Bandwidth Generously Provided by pair Networks
Your skill will accomplish
what the force of many cannot
 
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?


Comment on Re: Random numbers and substitution

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://907422]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others having an uproarious good time at the Monastery: (4)
As of 2014-09-17 01:17 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    How do you remember the number of days in each month?











    Results (55 votes), past polls