Beefy Boxes and Bandwidth Generously Provided by pair Networks
laziness, impatience, and hubris
 
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 meditating upon the Monastery: (8)
As of 2014-12-27 02:24 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    Is guessing a good strategy for surviving in the IT business?





    Results (176 votes), past polls