This produces the results you want in one run through @array - 5 steps - rather than $num steps. One of the other examples given above also attempts to do this, but I can't get the code to work, so here's mine.
NOTE: $n is created global here, overwriting any other global or local $n in use. I couldn't do a my statement without using a second line.
In reply to Re: Seek one liner for distributing an integer
by TedPride
in thread Seek one liner for distributing an integer
by johnnywang
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |