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

Re: problem with hash keys

by marcink (Monk)
on Jun 17, 2001 at 07:13 UTC ( [id://89127]=note: print w/replies, xml ) Need Help??


in reply to problem with hash keys

Actually, the fact that you get keys from #1 and #2 in correct order is pure coincidence -- a hash does not remember sequence of assignements. If you want to keep that information you'll have to create an array for keeping key order.

Another option is to use the sort function -- in your examples you use alphabetical order, so if that is what you want you can use something like this:

foreach my $k ( sort keys %GRAMMAR ) { print "$k\n"; }


-mk

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others imbibing at the Monastery: (8)
As of 2024-04-23 13:06 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found