Beefy Boxes and Bandwidth Generously Provided by pair Networks
Clear questions and runnable code
get the best and fastest answer
 
PerlMonks  

Re: Exists in HASH issue

by snadra (Scribe)
on Jul 22, 2003 at 08:17 UTC ( #276653=note: print w/ replies, xml ) Need Help??


in reply to Exists in HASH issue

Hello,

you should read
perldoc perlvar
first, to understand how hashes work. As said before, they are not sorted in any way.
But you can print them out sorted or do something else with them in a sorted way.
This would cause a numerical order:

foreach (sort {$a <=> $b} keys %hash) { # do something with $hash{$_} ... }
To sort them lexically just use:
foreach (sort keys %hash) { # ... }
Read 'perldoc -f sort' for more information.

snadra


Comment on Re: Exists in HASH issue
Select or Download Code

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others making s'mores by the fire in the courtyard of the Monastery: (5)
As of 2014-09-22 01:19 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    How do you remember the number of days in each month?











    Results (176 votes), past polls