#!/usr/bin/perl use Tk; use Tk::Text; my $mw=tkinit; my $text = $mw->Scrolled('Text')->pack; $text->bind('',[sub { &check_limit }]); $mw->Button(-text=>'Press Me', -command=>sub { $text->insert('end',$i++."\n"); $text->see('end'); &check_limit; })->pack; $mw->Button(-text=>'Exit', -command=>sub {exit})->pack; for (1..198){ $text->insert('end',$_."\n"); $text->see('end'); } MainLoop; sub check_limit{ $text->delete('1.0', "end -200 lines"); }