my $file = 'input.txt'; open STDLOG, "$file" or die("$file file cannot be opened: $!\n"); while (defined(my $row = )) { chomp $row; print "Current line is: $row \n"; # here i want to print the previous line }