Beefy Boxes and Bandwidth Generously Provided by pair Networks
good chemistry is complicated,
and a little bit messy -LW
 
PerlMonks  

Re: Simplifying for loop and applying multiple push function

by NetWallah (Canon)
on Dec 15, 2005 at 04:59 UTC ( [id://516859]=note: print w/replies, xml ) Need Help??


in reply to Simplifying for loop and applying multiple push function

I would question choice of the data structure used.

Given just the context in the OP's question, I would structure %hash as an array, and the problem practically solves itself.

my @arr = qw(one two three); my @one=@arr; my @two = 1..$#one+1;
This, ofcourse, assumes the indices (or keys) are sequential, numeric. If this is NOT the case, it is still more convenient to look at the %hash as an array of tuples, and code it as an AOA, since there seems to be an implied requirement to retrieve elements in a particular order.

     You're just jealous cause the voices are only talking to me.

     No trees were killed in the sending of this message.    However, a large number of electrons were terribly inconvenienced.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others cooling their heels in the Monastery: (5)
As of 2024-04-18 19:42 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found