5. TkPerl / X11 / 動的検索

#!/usr/local/bin/tkperl
(#4と同じ)
$text = $mw->Entry(-relief => 'sunken', -width => 60);
$text->bind("<Return>", sub { &lookup($text->get); });
$text->bind("<KeyPress>",
	sub {
		my $w = shift;
		my $pat = $text->get;
		&lookup($pat) if length($pat) > 1;
	});
$text->pack;

sub keypress {
	my $w = shift;
	my $pat = $text->get;
	&lookup($pat) if length($pat) > 1;
}