Keep the previous line in a variable or at least keep its length or position (via tell()) in a variable to seek() back if you need:
--my $p; while(<FILE>){ #du stuff if( prevous line needed and defined $p ){ seek FILE, -(length()+$p), 1; my $prevous_line = <FILE>; # next <FILE> will return the current line again, # so call it again before going on! } } continue { $p = length() }
In reply to Re: grabbing previous line in a log
by fruiture
in thread grabbing previous line in a log
by adonai
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |