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:
$a = 1
$b = 2
I am trying to figure out a way so that were I to run code like this:
print "enter username:";
# Whatever the solution to my problem is
print $a + $b;
It would show up as:
the only thing I can figure out to do is make the .usr file:
with the perl:
chomp($a = <USERFILE>);
chomp($b = <USERFILE>);
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.