in reply to How do I remove an element from any array while iterating over it in a loop?

Use redo instead of next inside your unless ($uid) {} block. When you splice out an element, the remaining elements are shifted down by 1. After the splice, $i has the index of the next element, but then the for loop increments it. redo skips the increment.
  • Comment on Re: How do I remove an element from any array while iterating over it in a loop?