in reply to Re: Adding an new element after every 5th element in array
in thread Adding an new element after every 5th element in array

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 }
It helps to remember that the primary goal is to drain the swamp even when you are hip-deep in alligators.