in reply to Instructive bug

Since I have no way of knowing exactly what type of data you have...
I think it might be
while ($cur_balance < ($balance * $i / $slice_count)) { $cur_balance += $cur_balances->[++$select]; }
that is killing you. If the data is such that @$cur_balances can be exhausted, then the while loop will never end because $cur_balances->[++$select] will keep returning 0.

_____________________________________________________
Jeff[japhy]Pinyan: Perl, regex, and perl hacker, who'd like a (from-home) job
s++=END;++y(;-P)}y js++=;shajsj<++y(p-q)}?print:??;