Clear questions and runnable code
get the best and fastest answer
Working with a legable config fileby phoenix9 (Novice)
|on Apr 03, 2004 at 02:12 UTC||Need Help??|
phoenix9 has asked for the
wisdom of the Perl Monks concerning the following question:
I have a friend who is writing a text based game, but as yet it had no save capabilities. I told him I'd right a save and load sub-routine for him because while im still new to it i know how to use filehandelers alot better than him.
Due to the simplicity of the game all that I need it to due is store variables in a text file from one running of the game until the next. The problem is I wanted the text file to be understandable instead of just a list of numbers so say the file (named test1.usr in a subfolder of the current directory named configs) is like this:
I am trying to figure out a way so that were I to run code like this:
It would show up as:
the only thing I can figure out to do is make the .usr file:
with the perl:
the only thing I can do with the current config (.usr) file is print it to STDOUT or another file. How can I keep the current formatting (and therfore legability) but still have the disired outcome.
P.S. this is a test version of the code. In the final it will be keeping track of actual information and will not just print 3. However, I bilieve the solution to this problem will work in the final version.