I know this must be easy in Perl using regular expressions, but I don't know Perl:
There are 2 files.
The first line of each file is a header.
Type is optional. If it starts with #, it is a comment, not a type.
Comments are optional.
For every line in the Overrides file, if there is a matching Name in the Arguments file, substitute the entire Overrides line in the Arguments file.
Except, if the Type is "skip" (no quotes) do not override the Arguments file.
If the Name does not appear in the Arguments file, append the Override line to the Arguments file.
For example, the following 2 files update the final file:
Original Arguments
Overrides
New Arguments
There are 2 files.
Arguments file
Overrides file
Structure in both files is: Name<tab>Value<tab>Type<tab>CommentOverrides file
The first line of each file is a header.
Type is optional. If it starts with #, it is a comment, not a type.
Comments are optional.
For every line in the Overrides file, if there is a matching Name in the Arguments file, substitute the entire Overrides line in the Arguments file.
Except, if the Type is "skip" (no quotes) do not override the Arguments file.
If the Name does not appear in the Arguments file, append the Override line to the Arguments file.
For example, the following 2 files update the final file:
Original Arguments
Code:
Name<tab>Value<tab>Type<tab>Comment
arg1<tab>val1<tab>const<tab>#Dont change this
arg2<tab>val2<tab>#Dont change this either
arg3<tab>val3<tab>#Override this
arg4<tab>val4<tab>const<tab>Override this, too
arg5<tab>val5
Code:
Name<tab>Value<tab>Type<tab>Comment
arg6<tab>val6<tab>#Append this
arg7<tab>val7
arg2<tab>val2a<tab>skip<tab>#Dont use this replacement
arg4<tab>val4a<tab>#Override with this
arg3<tab>val3a<tab>const<tab>#Replace with this
Code:
Name<tab>Value<tab>Type<tab>Comment
arg1<tab>val1<tab>const<tab>#Dont change this
arg2<tab>val2<tab>#Dont change this either
arg3<tab>val3a<tab>const<tab>#Replace with this
arg4<tab>val4a<tab>#Override with this
arg5<tab>val5
arg6<tab>val6<tab>#Append this
arg7<tab>val7