in reply to Re^2: How to loop over two lines, alter a value in the current line and save it to the previous line?
in thread How to loop over two lines, alter a value in the current line and save it to the previous line?

Correct, but it is not used anymore at all within the loop.

  • Comment on Re^3: How to loop over two lines, alter a value in the current line and save it to the previous line?

Replies are listed 'Best First'.
Re^4: How to loop over two lines, alter a value in the current line and save it to the previous line?
by rjc33 (Sexton) on Jan 07, 2016 at 11:51 UTC
    I'm afraid I don't understand, by $previous_line always being the first line it affects all of the variables in the loop. The loop starts on line 2, with the previous line being line 1; in the next iteration I'd like it to be on line 3, with the previous line being line 2 (and so on).

      Why do you need $previous_line if you already have @previous_columns?

        Apologies, I should have said that it makes the values within @previous_columns always refer to those in the first line. So for example in the 2nd iteration of the loop @previous_columns holds values from the first line, when I want to hold values from the second line (while the loop is performing actions on the 3rd line).