# select everything $lb->selectionSet(0, 'end' ); #### @selected = $lb->curselection; unless (@selected) { $lb->selectionSet(0, 'end' ); } foreach (@selected) { # do something with the index in $_ }