#!/usr/bin/perl use strict; use Tk; my $selected_text; my $mw = tkinit; my $lb = $mw->Scrolled( "Listbox", -scrollbars => "e", -selectmode => "single", )->pack; $mw->Label( -textvariable => \$selected_text )->pack; $lb->insert( 'end', qw/w2200 w2465 W2475 W2420/ ); $lb->bind( '', sub { # I don't use an array because -selectmode eq 'single' my $selection_index = $lb->curselection(); if ( $selection_index eq '' ) { $selected_text = "Nothing selected"; } else { $selected_text = $lb->get($selection_index); $lb->delete($selection_index); } } ); MainLoop;