http://qs321.pair.com?node_id=1083520


in reply to Re^4: Iterating through an array using multiple loops and removing array elements
in thread Iterating through an array using multiple loops and removing array elements

Unless I misunderstood, didn't you say the next top entry is derived from the first element in your new list of kept elements? If this is the case, the following line takes care of the problem. If this is not the case, then it would be helpful to have a more explicit set of specs for the script.
my ( $top_entry, @entries ) = @_;