#!/usr/bin/perl use strict; use warnings; use Tk; use Tk::HList; my $mw = MainWindow->new(); my $hlist = $mw->HList( -itemtype => 'text', # -selectmode => 'multiple', -selectmode => 'extended', -browsecmd => \&bc, ); my $text = $mw->Text(); my @words = qw( aback abaft abandon babble babies baboon cabal cabana cabaret ); $hlist->add($_, -text=>$_) foreach qw(a b c); foreach ( @words ) { my $first = substr($_, 0, 1); $hlist->add("$first.$_", -text=>$_); } $hlist->pack(-side => 'top', -fill => 'both', -expand => 1); $text ->pack(-side => 'bottom', -fill => 'both', -expand => 1); MainLoop; sub bc { my $sel = join "\n", $hlist->infoSelection(); $text->delete('1.0', 'end'); $text->insert('end', $sel); }