use strict; use warnings; use Tk; my $mw = new MainWindow; my $text = $mw->Text(qw/-width 40 -height 10/)->pack; my $current_color = "black"; $text->configure(-insertbackground => $current_color); $text->configure(-cursor => "arrow"); my $button = $mw->Button(-text => "Quit", -command => sub { exit })->pack; $text->bind('<>', sub{warn "text changed\n"} ); MainLoop; #### my $len; .. $text->bind('<>', sub{ if ($len != length $text->Contents ){ $len = length $text->Contents; warn "text changed ($len)\n"; $text->editModified(0) } } ); #### $text->bind('<>', sub{ if ($len ne $text->Contents ){ $len = $text->Contents; warn "text changed\n"; $text->editModified(0) } } );