Hi,
While reading each line in a file, If I find a certain number, I need to
increment a digit within that number. For example, when reading through my
file, I expect to find the following line.
#define DS_FILEVERSION 7,0,0,0462
What I want to do is have the ability to increment the first two zero's
after the 7 on demand. I may accasionaly want to increment the first zero,
making the number 7,1,0,0462, or a I may want to just increment the second
zero, making the number 7,0,1,0462
Here is how I have been trying to go about this. The code below bumps the
first zero just fine, resulting in the number being 7,1,0,0462. The problem
is that I can't figure out how to make it bump the second zero, resulting in
7,0,1,0462
=================================================================
if (!open(BASEFILE, $base_version_file)){
push(@g_fatal_errors, "$!, $base_version_file in
BumpBaseVercommn_File");
&GameOver(1);
}
if(!open(TEMPFILE, ">temp.txt")){
push(@g_fatal_errors, "$!, temp.txt in BumpBaseVercommn_File");
&GameOver(1);
}
while(<BASEFILE>)
{
if (/(\d,\d),(\d+),(\d{4})/){
if (!s/$2/sprintf("%0ld", $& + 1)/e){
&Debug("Unable to bump BaseVercommn.h in
BumpBaseVercommn_File, the build will be aborted!");
&GameOver(1);
}
}
print(TEMPFILE);
}
close(BASEFILE);
close(TEMPFILE);
if(!unlink($base_version_file)){
push(@g_fatal_errors, "$!, $base_version_file in
BumpBaseVercommn_File");
&GameOver(1);
}
if(!rename("temp.txt", $base_version_file)){
push(@g_fatal_errors, "$!, Could not rename temp.txt to
$base_version_file in BumpBaseVercommn_File");
&GameOver(1);
}
=================================================================
Thanks in advance for your help,
Ryan