in reply to Print all lines in a file except the last two
This will remove the last two lines in a file.open(F, '+<afile.txt') || die 'cannot open afile.txt'; while (<F>) { push(@addrs, tell(F)) unless eof(F); } truncate(F, $addrs[-2]) || die 'cannot truncate afile.txt';
|
|---|