#!/usr/bin/perl my $lines = shift || 10; my @buf; while( <> ) { push @buf, $_; shift @buf if @buf > $lines } print @buf; exit 0;