truncate combined with tell seems to be pretty straight-forward:
open my $fh, '+<', 'test.txt' or die $!; my $last_matched = 0; my $told = 0; while( my $line = <$fh> ) { my $matched = $line =~ m/SIL$/; truncate $fh, $told and last if $matched && $last_matched; $last_matched = $matched; $told = tell $fh; } close $fh or die $!;
Dave
In reply to Re: removing lines that are in the end of a file
by davido
in thread removing lines that are in the end of a file
by bhargavkanakiya
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |