#!/usr/bin/perl use warnings; use strict; use Tk; my $mw = tkinit; my @employs = ('A'..'Z'); my @active = (); my $l1 = $mw->Scrolled('Listbox', -listvariable => \@employs, -scrollbars =>'osow')->pack( -side => 'left' ); my $l2 = $mw->Scrolled('Listbox', -listvariable => \@active, -scrollbars =>'osow')->pack( -side => 'left',-padx=>10 ); my $button = $mw->Button(-text=>'Print Active', -command => sub{ print "@active\n"} )->pack(-side=>'left'); $l1->bind( '', sub { update( $_[0], $l2 ) } ); $l2->bind( '', sub { update1( $_[0], $l1 ) } ); MainLoop; sub update { my ( $src, $dst ) = @_; my $index = $src->curselection; if ($index) { my $value = $src->get($index); # print "$value\n"; @employs = grep { $_ ne $value } @employs; push @active, $value; @employs = sort @employs; @active = sort @active; } } sub update1 { my ( $src, $dst ) = @_; my $index = $src->curselection; if ($index) { my $value = $src->get($index); # print "$value\n"; @active = grep { $_ ne $value } @active; push @employs, $value; @employs = sort @employs; @active = sort @active; } }