use Tk; my $mw = MainWindow->new; my $text = $mw->Text->pack; my $bFrame = $mw->Frame->pack(qw/-side bottom/); $bFrame->Button( -text => "Check Text", -command => sub { if ($text->index('end - 1c') == 1) { print "Text is empty\n"; } else { print "Text contains data\n"; } })->pack(qw/-side left/); $bFrame->Button( -text => "Clear Text", -command => sub { $text->delete("1.0", 'end'); })->pack(qw/-side left/); MainLoop;