Apr 24, 2000, 5:03 PM
Post #1 of 2
Reading & writing variables to a datafile
As i think cure mentioned to someone previously, it's possible to put
in a script to retrieve stored variables.
I then want to take these variables, change them, and rewrite them back to the data file to update them each time the script is run.
The file should look like this;
$var1 = 'string';
$var2 = 3;
But how do i pattern match the variables on each line? That is to say find the line starting with;
and replace with;
$var1 = 'new string';
If these lines start with a $ won't perl misinterperete that?
Won't perl also misinterprete;
print DATAFILE "$var1 = 'new string';";
won't it instead print;
string = 'new string';
or is there a better way of doing this kind of thing?