Beefy Boxes and Bandwidth Generously Provided by pair Networks
Don't ask to ask, just ask
 
PerlMonks  

Re: DB_file and DB_HASH

by crazyinsomniac (Prior)
on Jun 05, 2002 at 00:08 UTC ( #171680=note: print w/replies, xml ) Need Help??


in reply to DB_file and DB_HASH

visit the DB_File documentation, and then use a BTREE to store your data. A hash is not sorted. A balanced tree is.

 
______crazyinsomniac_____________________________
Of all the things I've lost, I miss my mind the most.
perl -e "$q=$_;map({chr unpack qq;H*;,$_}split(q;;,q*H*));print;$q/$q;"

Replies are listed 'Best First'.
Re: Re: DB_file and DB_HASH
by perrin (Chancellor) on Jun 05, 2002 at 00:14 UTC
    BTREE is faster too, according to a benchmark posted here a while back.
      Thanks but my question is not to get the data in the sorted order but the order in which the data was inserted.For exam if I did 323|Val and 121|Val, I would like to get 323 first.Sorry if I confused.Is there any way to achieve this using BTREE,please advise

        Something like Storable or Freeze/Thaw might do what you want. Check the perldoc

        It sounds more like you're using it as an array then. Maybe you should use the Queue instead.

        If you need both insertion order access and random access by key you will have to store a separate array that keeps track of the order that keys were inserted.

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others scrutinizing the Monastery: (3)
As of 2019-07-21 00:18 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    If you were the first to set foot on the Moon, what would be your epigram?






    Results (7 votes). Check out past polls.

    Notices?