in reply to Re^2: Using Map to Create AoA
in thread Using Map to Create AoA
If this is the case, then we do this:
use Data::Dumper; use strict; use warnings; my $arr = ['A -4 C','C -4 B','B -4 A','A -2 C','C -3 B']; my @a = map {[split " ", $arr->[$_] . " $_"]} (0 .. @$arr - 1); print Dumper(\@a);
Which gives:
$VAR1 = [ [ 'A', '-4', 'C', '0' ], [ 'C', '-4', 'B', '1' ], [ 'B', '-4', 'A', '2' ], [ 'A', '-2', 'C', '3' ], [ 'C', '-3', 'B', '4' ] ];
|
|---|