Beefy Boxes and Bandwidth Generously Provided by pair Networks
Don't ask to ask, just ask

How can I make my hash remember the order I put elements into it?

by faq_monk (Initiate)
on Oct 08, 1999 at 00:20 UTC ( #633=perlfaq nodetype: print w/replies, xml ) Need Help??

Current Perl documentation can be found at

Here is our local, out-dated (pre-5.6) version:

Use the Tie::IxHash from CPAN.

    use Tie::IxHash;
    tie(%myhash, Tie::IxHash);
    for ($i=0; $i<20; $i++) {
        $myhash{$i} = 2*$i;
    @keys = keys %myhash;
    # @keys = (0,1,2,3,...)

Log In?

What's my password?
Create A New User
[LanX]: how difficult is IP spoofing in the intranet?
[Your Mother]: I'm curious to hear the answer.
[LanX]: never mind
[LanX]: we have a vulnaribility task force in the company flooding our servers with fake attacks
[LanX]: I called them complaining about the load, and they told me to just ignore their IP
[LanX]: ... in the logs
[LanX]: but I tend to just reject it by an apache rule
[shmem]: LanX: start a DDOS upon their servers :-P

How do I use this? | Other CB clients
Other Users?
Others surveying the Monastery: (9)
As of 2018-03-19 14:29 GMT
Find Nodes?
    Voting Booth?
    When I think of a mole I think of:

    Results (240 votes). Check out past polls.