Nevermind, this is completely wrong. :(
I think hdb's example could be simplified a bit plus avoid any old-size remainder problems like this:
while( @array ) { push @newarray, splice @array,0,$nset; next if @newarray % ($nset * $every); # no need for a counter w +ith % op push @newarray, $newelement; # add the new element }
In reply to Re^2: Adding an new element after every 5th element in array
by boftx
in thread Adding an new element after every 5th element in array
by dvinay
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |