My goal is to replace all named constants in a *.bas file with their corresponding values, then append a comment to the line with the value-constant pair for future reference.
For example, I want to change this line:
Print #lngFile, rst.GetString(adClipString, -1, ",", vbNullString);
To this:
Print #lngFile, rst.GetString(2, -1, ",", vbNullStrings); '2=adClipString
Where the ADODB constant adClipString is replaced with its long value 2, and a comment is appended to the line.
The closest I've gotten is the following:
perl -pi -e 's/adClipString(.+\n)/2$1\x272=adClipString\n/' -- somefile.bas
...but I can't figure out how to exclude the \n from the capturing group without also overwriting every line in the file. As written, the comment is placed on a new line (which is not what I want). I'm sure the answer is right in front of me.
I'm new to perl, having only run it on the command line. I'm sure there is a better [read: working] way to approach this.