print "TOP\n"; while( <> ) { last if $. > 10; # $. is the current line number within the file. print "$_\n"; } print "BOTTOM\n";