Deleting lines between two instances of interest within a file in tcl
<p>Earlier I had asked some help to delete and replace contents of a file. With Peter's help and example that problem was solved (<a href="https://stackoverflow.com/questions/36234680/split-a-line-from-a-file-to-replace-elements-in-tcl">See this post</a>). However it created another one, this issue relates to deleting lines.</p>

<p>So here is the question, I can delete lines for every instance of <strong><em>Prefix_1</em></strong> that appears in the file.</p>

<p>However there are lines between two instances that are skipped (because the line does not start with Prefix_1), hence is left in the file.</p>

<p>I do know that Line starts with Prefix_1 followed by a dot then variable name and ends with either space and equal sign or colon.</p>

<p>Every line that ends with colon has a table associated with it.</p>

<p>Would I identify the two classes of lines one ending with space and equal sign and the other with colon. Then, whenever colon is detected delete all line until next instance of Prefix_1 is detected?</p>

<pre><code>Prefix_1.Var1 = -2
Prefix_1.Var2 = 1
Prefix_1.Var3:
    1.1 1.3 1.8 15 1.9 0.1 16 71 31 16 12 1 881 199 19 100 1000 1005 1005 1005
Prefix_1.Var4 = 1
Prefix_1.Var5:
    40 50 75 100 150
Prefix_1.Var6:
    4
    7
    15
    25
    35
    45
Prefix_1.Var7:
    #TABLE 30 2 5 6
    70       70       70       70       70       100      100
    81       80       80       100      100      81       80
    80       100      100      81       80       80       100
    100      82       81       81       100      100      87
    87       87
Prefix_1.Var8 = 1
Prefix_1.Var9 = 65
Prefix_1.Var10:
    255 255 255 255 255 255 255 255 255 255
Prefix_1.Var11:
    0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 1 1 1 1 1 1 1 1 1 1 1 1 2 1 2 6 1 2 2 0 0 0 0 0 0 0 0
Prefix_1.Var12 = 30
</code></pre>

<p>After I delete all lines with Prefix_1, I'm still left with these lines which fall in between two instances of Prefix_1.</p>

<p>I want to delete these too.</p>

<pre><code>1.1 1.3 1.8 15 1.9 0.1 16 71 31 16 12 1 881 199 19 100 1000 1005 1005 1005
40 50 75 100 150
4
7
15
25
35
45
#TABLE 30 2 5 6
70       70       70       70       70       100      100
81       80       80       100      100      81       80
80       100      100      81       80       80       100
100      82       81       81       100      100      87
87       87
255 255 255 255 255 255 255 255 255 255
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 1 1 1 1 1 1 1 1 1 1 1 1 2 1 2 6 1 2 2 0 0 0 0 0 0 0 0
</code></pre>