Beefy Boxes and Bandwidth Generously Provided by pair Networks
go ahead... be a heretic
 
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

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://276653]
help
Chatterbox?
[hippo]: That was around April 1994. Fun times.
[hippo]: They had purchased some shiny new 486 DXs the year before but crippled them by installing Win 3.1. I demo'd Linux with X on them to the department head and got the go-ahead to wipe Windows and install the new hotness.
[marto]: glory days ;)

How do I use this? | Other CB clients
Other Users?
Others meditating upon the Monastery: (12)
As of 2018-06-22 09:54 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Should cpanminus be part of the standard Perl release?



    Results (124 votes). Check out past polls.

    Notices?