shan_emails has asked for the wisdom of the Perl Monks concerning the following question:
my $file = 'input.txt'; open STDLOG, "$file" or die("$file file cannot be opened: $!\n"); while (defined(my $row = <STDLOG>)) { chomp $row; print "Current line is: $row \n"; # here i want to print the previous line }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: How to get previous line of the file while processing current line in while loop
by Nikhil Jain (Monk) on Mar 29, 2011 at 07:37 UTC | |
|
Re: How to get previous line of the file while processing current line in while loop
by JavaFan (Canon) on Mar 29, 2011 at 09:17 UTC | |
|
Re: How to get previous line of the file while processing current line in while loop
by Anonymous Monk on Mar 29, 2011 at 15:01 UTC |