Beefy Boxes and Bandwidth Generously Provided by pair Networks
XP is just a number
 
PerlMonks  

Re: Re: Re: problem with hash keys

by ariels (Curate)
on Jun 17, 2001 at 15:34 UTC ( #89151=note: print w/ replies, xml ) Need Help??


in reply to Re: Re: problem with hash keys
in thread problem with hash keys

Then you can additionally store for each hash the order in which its keys are in:

# ... push @grammar_keys, $1 unless exists $grammar{$1}; $grammar{$1} = $2; # ... print "$k\n" for my $k (@grammar_keys);
(I've also taken the liberty of using lowercase variable names; you should probably use all-uppercase names only for special global variables).

Or you can use a module like Tie::IxHash, which implements hashes with ordered keys just like you want.


Comment on Re: Re: Re: problem with hash keys
Download Code

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others studying the Monastery: (9)
As of 2015-07-06 14:48 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 (75 votes), past polls