use warnings; use strict; use Tk; my $mw = MainWindow->new; my $index = 'Line: 1 - Column: 0'; my $txt = $mw->Scrolled('Text', -scrollbars => 'se', -wrap => 'none', -background => 'white', -width => 40, -height => 30, -selectbackground => 'skyblue', -insertwidth => 5, -borderwidth => 3, -highlightcolor => 'blue', ### after visit -highlightbackground => 'red', ### default before visit -padx => 5, -pady => 5, )->pack(); my $label = $mw->Label( -textvariable => \$index )->pack(); $txt->bind( '', \&update_index ); MainLoop; sub update_index { my ( $line, $column ) = split( /\./, $txt->index('insert') ); $index = "Line: $line - Column: $column"; }