sub remove_item { my ($i, %del) = (0); @del{@_} = undef; @items = grep { $i++ and !exists $del{$_} and $index -= ($i < $index) } @items; }