#!/usr/bin/perl # # given a file name as an argument, # read the file until eof, back up # one line and truncate the file there. # in short, "delete the last line of a file" # my $file=shift(@ARGV); open(FILE,"+<$file") or die; while () { if (eof(FILE)) { seek(FILE,-(length($_)),2) or die; truncate(FILE,tell(FILE)) or die; } } close FILE;