Note that I used an simple arrayref as source data, as I did not see the reason to have an array ref to an array ref if the first array as only one element. But that is quite easy to change if this is really what you need.DB<2> $mref = [ qw / 5 4 4 2 4/ ]; DB<3> x \$mref 0 REF(0x600500ac8) -> ARRAY(0x600509918) 0 5 1 4 2 4 3 2 4 4 DB<4> $nref = [ map {[$_]} @$mref ]; DB<5> x \$nref 0 REF(0x600500708) -> ARRAY(0x6005e8c88) 0 ARRAY(0x6005ea970) 0 5 1 ARRAY(0x6005f3d20) 0 4 2 ARRAY(0x6004bdfd0) 0 4 3 ARRAY(0x60060d270) 0 2 4 ARRAY(0x6005e8c40) 0 4
Edit: The post by 2teez below reminded me that the Data Dumper module gives an output somewhat cleaner than the x function of the debugger. Since I had still my debugging screen as above, with the data structures still there, this is the data dumper output:
DB<6> use Data::Dumper; DB<7> print Dumper \$nref $VAR1 = \[ [ '5' ], [ '4' ], [ '4' ], [ '2' ], [ '4' ] ];
And if the input data structure is really a ref to an AoA, the code can be changed as follows:
producing the same resulting data structure and output as above.DB<8> $mref = [ [ qw / 5 4 4 2 4/ ], ]; DB<9> $nref = [ map {[$_]} map {@{$_}} @$mref ];
In reply to Re: Convert Column Matrix into Row Matrix using Math::MatrixReal
by Laurent_R
in thread Convert Column Matrix into Row Matrix using Math::MatrixReal
by John007
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |