#!/usr/bin/perl my $FILE = "the_log_file"; my $MAXSIZE = 2**20; # 1 meg exit 0 unless -s $FILE > $MAXSIZE; @ARGV = $FILE; # set diamond to file undef $/; # slurp mode $^I = ""; # enable in-place editing while (<>) { substr($_, 0, $MAXSIZE - length) = ""; # save last portion s/.*\n//; # toss one line so it comes out at a line boundary print; }