use Tk; use strict; use warnings; my $window = MainWindow -> new(); $window->geometry("520x580"); my $entry_frame = $window -> Frame()->pack(-side => "top"); my $entry = $entry_frame -> Entry (-width => 53, ) -> pack(-side => 'left'); $entry -> bind(''=> \&button_Click); $entry -> focus; my $button = $entry_frame -> Button (-text => "Search", -command => \&button_Click ) -> pack (-side => 'right'); my $display_field = $window -> Scrolled("Text",-scrollbars => 'e', ) -> pack(-side => 'top',-fill => 'y', -expand => 1); sub button_Click { my $now = time; my $file = "./data"; #text file about the size of 30 MB open my $data, '<', $file or die "Open failed: $!"; $display_field->delete('0.0','end'); my $query = $entry->get(); while (<$data>) { if(/$query/i){ $display_field->insert("end",$_); $window->update; } } $now = time - $now; my $time = sprintf("\n\nTotal running time: %02d:%02d:%02d\n\n", int($now / 3600), int(($now % 3600) / 60), int($now % 60)); $display_field->insert('end',$time); } MainLoop;