Beefy Boxes and Bandwidth Generously Provided by pair Networks
laziness, impatience, and hubris
 
PerlMonks  

Re^2: 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:02 UTC ( [id://1152162]=note: print w/replies, xml ) Need Help??


in reply to Re: 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?

Hi, thanks for your very quick answer. Yes, I would like my modifications reflected in $previous_line in the next iteration of the loop, so your suggestion makes a lot of sense. Unfortunately that change seems to make $previous_line always equal the first line of the file for some reason
  • Comment on Re^2: 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^3: How to loop over two lines, alter a value in the current line and save it to the previous line?
by hdb (Monsignor) on Jan 07, 2016 at 11:39 UTC

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

      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?

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://1152162]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others sharing their wisdom with the Monastery: (5)
As of 2024-04-23 06:17 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found