in reply to Re^2: Perl task function
in thread Perl task function

there is one error: when I splice the array it's size decreases, so the cycle doesn't check the next element.

There is no error in my implementation. It does all elements, if you start from the end and work backward. Hence why my loop uses reverse:

for reverse 0 .. $#$ref;

Your forward running C-style loop, using splice and requiring that you decrement $i & $n after deletions is rather clumsy and unperlish by comparison. But if that's what you're comfortable with, stick with it.


Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
"Science is about questioning the status quo. Questioning authority".
In the absence of evidence, opinion is indistinguishable from prejudice.
RIP an inspiration; A true Folk's Guy