in reply to grabbing previous line in a log
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() }
|
|---|