in reply to Managing Client Specific Hashes

I could then query those out and put them into a sorted hash.
What's that, a sorted hash?
Is there a way that I can have the hash pre-constructed in a seperate file and import the hash into my main program based on the user selection?
No, you can't dump nor load a hash "as is" to or from a file. You can dump and load the content of a hash to or from a file, but if you load it, the hash still needs to be constructed.

You can however make use of DBM files. Then the data will stay on disk (in its own formate), and you have a tied hash as interface. Whether or not that will be faster will depend on the size of the hash, the amount of queries and updates you are performing, the speed of your memory, CPU and disk, the size of your memory, the throughput of your I/O, etc. Only by testing it under production conditions you can be certain what's faster.

Of course, if all we are talking about is a handful of 11 entry hashes, it hardly matters which method you pick.

Abigail

Replies are listed 'Best First'.
Re: Re: Managing Client Specific Hashes
by Grygonos (Chaplain) on Jan 13, 2004 at 15:32 UTC
    That was a sample, the real hash is 63 elements.. nothing enormous.. but yes bigger than 11. When I say the hash is sorted I mean the keys are sorted when I use it. I know the hash itself is never really sorted.

    Grygonos
      63 elements is not much. Determining which method to load the hash is the fastest isn't worthwhile (unless you want to load thousands of them).
      When I say the hash is sorted I mean the keys are sorted when I use it.
      What do you mean by that? Does that mean you always sort the keys, and access the hash using the sorted keys? In that case, it looks like you shouldn't use a hash, but a sorted array instead.

      Abigail

        In my mind its bad to have arrays with 'willy-nilly' indexes... such as:index 9 is valid.. index 31 is valid... but 10 through 30 are not...this is bad practice correct? and yes they are always sorted when I use them. I would be sorting the array by index and not value... I'm not understanding why you think an array is a viable option... please explain that.. I would like to understand.


        Grygonos