in reply to Print preceding line from text database
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.
|
|---|