Beefy Boxes and Bandwidth Generously Provided by pair Networks
go ahead... be a heretic
 
PerlMonks  

Re: Using Map to Create AoA

by Dietz (Curate)
on Oct 16, 2005 at 15:58 UTC ( #500578=note: print w/ replies, xml ) Need Help??


in reply to Using Map to Create AoA

map { split(" ", $arr->[$_]) } 0..$#{$arr} should do

Update: Rereading your question this is not what you're seeking for. Following will save also the index.

map { [ split(" ", $arr->[$_]." $_") ] } 0..$#{$arr};

But as pg already said, there is no obvious advantage in storing the index.


Comment on Re: Using Map to Create AoA
Select or Download Code
Re^2: Using Map to Create AoA
by pg (Canon) on Oct 16, 2005 at 16:09 UTC

    This gives a flat structure:

    $VAR1 = [ 'A', '-4', 'C', 'C', '-4', 'B', 'B', '-4', 'A', 'A', '-2', 'C', 'C', '-3', 'B' ];
      Right!
      Sorry for untested code

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://500578]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others examining the Monastery: (10)
As of 2015-07-03 09:03 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (51 votes), past polls