Your code which I simplified below works fine.
How would @list get modified? That is the real question here.
You don't show any code for that.
Do you want a right-click menu to add/delete? Do you want an Add/Delete menu bar?
Adding a new element to the listbox means that
my @list = ( "a", "b", "c", "d", "e", "f" );
has been modified. Perhaps:
my @list = ( "a", "b", "c", "d", "e", "f","g" );
or perhaps ( "a", "b", "NEW", "c", "d", "e", "f" )
or perhaps ( "a", "b", "c")
I would be thinking of just deleting all element in the Listbox
and then re-insert the new elements from this modified list.
That is one way to change the contents of a Listbox.
It would be very helpful if you could describe what the user is
going to do that results in a different displayed Listbox contents?
I think there is a wrong thought model here. If you change the Listbox,
then you know you did that. Call the update Listbox routine. Or perhaps
the window with list box, fetches new data every time is is displayed.
My last thought would be a timed update every x seconds.
=================================
use strict;
use warnings;
use Tk;
my $mw = MainWindow->new();
my $lbox = $mw->Listbox()->pack();
my @list = ( "a", "b", "c", "d", "e", "f" );
$lbox->insert('end', @list );
$lbox->selectionSet('2'); #default starting selection in the box,"c"
$lbox->bind('<<ListboxSelect>>', sub{warn "new ListBox element selecte
+d!\n"} );
MainLoop;