package Tk::MyText;  use Tk::Text;  use Tk::Derived;  use base qw(Tk::Derived Tk::Text);  Tk::Widget->Construct('MyText');  sub insert {      my($w, @args) = @_;      $w->SUPER::insert(@args)          unless $w->cget('-maxlength');      my $t = $w->get('1.0', 'end');      $t =~ s/\n$//s;      $w->SUPER::insert($args[0],          substr(join( '' => @args[1 .. $#args]),          0, $w->cget('-maxlength') - length $t));  }  sub Populate {      my($w, $args) = @_;      $w->ConfigSpecs(-maxlength => [qw(PASSIVE maxLength MaxLength), undef]);      $w->SUPER::Populate($args);  } 1;