#!/usr/bin/perl use strict; my $bigfile = shift or die "Usage: $0 filename \n"; my $charsperline = 80; ## A rough guess, adjust as needed my $linesback = shift || 10; ## How many "lines" back to read open(BIG, $bigfile) or die "Could not open $bigfile: $!\n"; ## Make a reasonable guess as to how far back to go. my $gobackchars = $linesback*$charsperline; ## Figure out how big it is, so we don't go *too* dar back: my $filesize = -s $bigfile; $gobackchars = $filesize if $gobackchars > $filesize; ## Go to the end of the file minus that many characters seek(BIG,-$gobackchars,2); ## We probably arrived in the middle of a line, ## so throw out everything until the start of a new line ## (As determined by $/) ; ## Now we print out the rest of the lines: print while(); close(BIG);