use strict; use warnings; open(my $fh, '<', "$file") or die $!;#use three argument open my $previous_line = q{}; #initially previous line would be empty while(my $current_line = <$fh>){ chomp; print"$current_line\n"; print"$previous_line\n"; #assign current line into previous line before it go to next line $previous_line = $current_line; } close($fh);
In reply to Re: How to get previous line of the file while processing current line in while loop
by Nikhil Jain
in thread How to get previous line of the file while processing current line in while loop
by shan_emails
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |