use warnings; use strict; use Tk; my $mw = MainWindow->new(); my $tx = $mw->Text()->pack(); $mw->repeat(1000, \&readTextWidget); my $CursorPosition="1.0";#starting index in Tk Text MainLoop; sub readTextWidget{ my @Text=$tx->dump($CursorPosition,'end'); my $TextChunk = $Text[1]; $CursorPosition= $Text[5]; if ($text ne "current"){#skip Tk:Text indicators my @words = split / /, $TextChunk ; foreach my $word (@words) { print "$word\n"; } } }