<?xml version="1.0" encoding="windows-1252"?>
<node id="481198" title="Re^3: Splitting multiline scalars into different array entries" created="2005-08-05 07:23:19" updated="2005-08-11 08:35:02">
<type id="11">
note</type>
<author id="87452">
broquaint</author>
<data>
<field name="doctext">
Ah yes, it seems I missed the transposition.

&lt;code&gt;
use Algorithm::Loops 'MapCar';

my @results = map {
  grep(/\n/,@$_)
    ? MapCar {[@_]} map([split "\n"], @$_)
    : $_
} @AoA;
&lt;/code&gt;

And to be sure:
&lt;readmore&gt;
&lt;code&gt;
use Test::More tests =&gt; 1;

my @AoA = (
    [qw/single cell values/],
    [qw/are really easy/],
    [ "but\nmultiline\nstilton",
      "these\ncells\nis",
      "aren't\nsuck\ngreat" ],
    [qw/back to life/],
    [qw/back to reality with more cells/]
);

my $desired = [
    [ 'single',    'cell',   'values' ],
    [ 'are',       'really', 'easy' ],
    [ 'but',       'these',  'aren\'t' ],
    [ 'multiline', 'cells',  'suck' ],
    [ 'stilton',   'is',     'great' ],
    [ 'back',      'to',     'life' ],
    [ 'back', 'to', 'reality', 'with', 'more', 'cells' ]
];

use Algorithm::Loops 'MapCar';
my @results = map {
  grep(/\n/,@$_)
    ? MapCar {[@_]} map([split "\n"], @$_)
    : $_
} @AoA;

is_deeply \@results, $desired, "The arrays match!";
&lt;/code&gt;
&lt;/readmore&gt;
&lt;div class="pmsig"&gt;&lt;div class="pmsig-87452"&gt;
HTH
&lt;p/&gt;
&lt;tt&gt;_________&lt;br&gt;&lt;u&gt;broquaint&lt;/u&gt;&lt;/tt&gt;
&lt;/div&gt;&lt;/div&gt;</field>
<field name="root_node">
481165</field>
<field name="parent_node">
481192</field>
</data>
</node>
