Dear ikegami,
[ split(" ", $arr->[$_]), $_ ]
would be better.
Thanks for your response. But please correct me
if I'm wrong. Your solution above does not give
the index, theirs do. Here is the example:
my $arr = ['A -4 C',
'C -4 B',
'B -4 A',
'A -2 C',
'C -3 B'];
my @res = decomp_a2aoa_wth_idx($arr);
sub decomp_a2aoa_wth_idx
{
my $arr = shift;
return map { [ split (" ",$arr->[$_],$_) ] } (0 .. @{$arr}-1);
}
__END__
# Prints this result
$VAR1 = [
['A','-4','C'],
['C -4 B'],
['B','-4 A'],
['A','-2','C'],
['C','-3','B']
];
Update: Yes it was my fault. I made the typo.
I apologize to ikegami for my carelessness. Thanks
to Tanktalus for mentioning it.
---
neversaint and everlastingly indebted.......
|