Hi, thanks for all your help. I just initially misused the word "cumulate", I'm trying to do exactly what you just quoted in italics but my current code falls just short. I want to alter the value in the 3rd column of each line based on some calculations using values from the same line and the previous line (so that has to be included somehow, although I'm open to completely different ways of doing it). So I want my loop to start on line 2, altering the 3rd column based on other values in line 2 and line 1; the next iteration would then alter the 3rd column of line 3 based on values in line 3 and line 2, and so on. My current code does this, the problem is that whatever is the $previous_line at the time contains the initial values from the file itself, I want it to contain the 3rd column value that I changed in the previous iteration of the loop.
So for example, if in the first 3 lines of the file my 3rd columns are 4, 6, 9. My loop will start on line 2, and say it will change 6 to 8. The next iteration will be on line 3, however when it accesses line 2 it uses the old value 6 when I need it to use the new value 8, and hence from the third line onwards my code gives me incorrect output. So I'm just looking for a way to save the changed value to the previous line for the next iteration of the loop.