in reply to Re^2: Delete last line of file with regex
in thread Delete last line of file with regex
In that case you could seek to a position close to the end-of-file, walk backward until you find a newline, use a regex to see if the last line matches, and if so, remove it. Then, truncate the file at the current position and append the modified string to it. This would work on a file of any size while using a minimal amount of memory.
|
---|
Replies are listed 'Best First'. | |
---|---|
Re^4: Delete last line of file with regex
by Anonymous Monk on Aug 06, 2020 at 16:40 UTC |
In Section
Seekers of Perl Wisdom