in reply to Using Map to Create AoA
There is no need to save the index as part of this, as that information is retained by the AoA itself. You have to make the best design decision "one truth is only stored once"
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; print Dumper(\@a);
This prints:
$VAR1 = [ [ 'A', '-4', 'C' ], [ 'C', '-4', 'B' ], [ 'B', '-4', 'A' ], [ 'A', '-2', 'C' ], [ 'C', '-3', 'B' ] ];
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Using Map to Create AoA
by neversaint (Deacon) on Oct 16, 2005 at 16:12 UTC | |
by Tanktalus (Canon) on Oct 16, 2005 at 16:21 UTC | |
by pg (Canon) on Oct 16, 2005 at 16:15 UTC |