in reply to Print preceding line from text database

At the end of the while loop's body, say $prev_line= $_; to save what you have before doing <I> again.

I'd also go ahead and used a named variable instead of relying on $_ to still hold the line. Something like:

my ($current_line, $prev_line); while($current_line=<I>){ chomp; @line = split(/\t/, $_); if($line[0] eq $GET{'id'}){ $found=1; last; } $prev_line= $current_line; } close(I); # value in $prev_line still good.