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.
In reply to Re^3: Perl task function
by BrowserUk
in thread Perl task function
by usr345
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |