Beefy Boxes and Bandwidth Generously Provided by pair Networks
Just another Perl shrine
 
PerlMonks  

Re: Exists in HASH issue

by snadra (Scribe)
on Jul 22, 2003 at 08:17 UTC ( [id://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

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others meditating upon the Monastery: (5)
As of 2024-04-16 05:30 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found