foreach my $row (@AoA) { my @foo = map { split /\n/ } @$row; for( my $i = 0; $i < $#foo; $i += $width ) { push @new_rows, [ @foo[ $i .. -1 + $i + $width ] ]; } } #### $VAR1 = [ [ 'single', 'cell', 'values' ], [ 'are', 'really', 'easy' ], [ 'but', 'multiline', 'stilton' ], [ 'these', 'cells', 'is' ], [ 'aren\'t', 'suck', 'great' ], [ 'back', 'to', 'life' ], [ 'back', 'to', 'reality' ], [ 'with', 'more', 'cells' ] ];