my $element_size = 3; my $group_size = 10; #adjust as needed for 5th, 7th, etc. my $block_size = $element_size * $group_size; # since "elements" are virtual my @new; while ( @old_array ) { if ( @old_array < $block_size ) { # don't add new if old is too small push(@new, @old_array); last; } push(@new, splice(@old_array,0,$block_size); # "shift" out of old push(@new,qw( create mount remove )); # new "element" added here } # UPDATE: added code to put remainder of @old_array onto @new if not # a full multiple.