Link to home
Start Free TrialLog in
Avatar of noshankus
noshankusFlag for Ireland

asked on

Perl/tk listbox delete specific element

Hi,

I have some tk code like:

$lb_src  = $f->Scrolled('Listbox', -scrollbars => "osoe")->pack(-side => "left");
foreach(@directoryInListing) {chomp $_;
  $listbox_src->insert("end", $_);
}

Grand. Then I have a specific element that I want to delete from the listbox. Order changes everytime (so that rules out ->delete(#, #)) - unless I run yet another check to find the correct ordering. But I'm sure there must be a simpler way to do this.

I want to write something like:
$var = "foo";
$listbox_src->delete('active'); or
$listbox_src->delete('$var');

Is this not possible??
Seems like there is so much room for improvement in tk =)

Thanks for your help.
Best regards,
Avatar of noshankus
noshankus
Flag of Ireland image

ASKER

And I don't want an answer about counting each element into a hash:

foreach(@directoryInListing) {chomp $_;
    $lb_src->insert("end", $_);
    $ohGodHash{$_} = $ohGodNumber;
    $ohGodNumber++;
}

cos I can do that =) Just wondering if there is an easier way.
Avatar of ozo
An easier way to count each element into a hash is

@ohGodHash{@directoryInListing}=(0..$#directoryInListing};
ASKER CERTIFIED SOLUTION
Avatar of ITcrow
ITcrow

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Ah nice. Close to what I was hoping for, and works well.

Thanks =)
Avatar of ITcrow
ITcrow

Glad it worked out.