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

Re: How do I keep the first key in a sorted hash?

by pajout (Curate)
on Feb 17, 2014 at 12:32 UTC ( #1075171=note: print w/replies, xml ) Need Help??


in reply to How do I keep the first key in a sorted hash?

As you probably know, hashes have not any order of keys by definition, so I see the simplest way to keep minimal key value in a special scalar variable.

But if you require 'special' hash, which naturally stores just one key/value pair, i.e. if new key/value pair is written into hash, one of them with greater key is deleted, you can implement your own hash using tie (http://perldoc.perl.org/perltie.html).

  • Comment on Re: How do I keep the first key in a sorted hash?

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others musing on the Monastery: (4)
As of 2020-05-27 23:10 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    If programming languages were movie genres, Perl would be:















    Results (162 votes). Check out past polls.

    Notices?