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:
It would show up as:print "enter username:"; chomp($uname=<STDIN>); $USERFILE='configs/'.$uname.'.usr'; open(USERFILE); # Whatever the solution to my problem is print $a + $b;
the only thing I can figure out to do is make the .usr file:enter usename:test1 3
with the perl:1 2
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.chomp($a = <USERFILE>); chomp($b = <USERFILE>);
In reply to Working with a legable config file by phoenix9
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |