#!/usr/bin/perl -- use strict; use warnings; use Tk; my $mw = MainWindow->new; my $filename; # Create necessary widgets my $f = $mw->Frame->pack( -side => 'top', -fill => 'x' ); $f->Entry( -textvariable => \$filename )->pack( -side => 'left', -anchor => 'w', -fill => 'x', -expand => 1 ); $f->Button( -text => "Exit", -command => sub { exit; } ) ->pack( -side => 'right' ); $f->Button(-text => "Find", -command => \&find) -> pack(-side => 'right'); my $t = $mw->Scrolled("Text")->pack( -side => 'bottom', -fill => 'both', -expand => 1, ); $t->insert( end => join "\n", 1 .. 10 ); $t->insert( 'end', "\nthe_the_the the\n"); $t->insert( 'end', "\nthe_the_the the\n"); MainLoop; sub find(){ #$t->FindNext(-forward, -exact,-nocase); my $result = $t->FindNext(-forwards, -exact, -nocase, "the"); print $result; }