in reply to Re: Algoritm for converting string to number?
in thread Algoritm for converting string to number?

Couldn't you do the same thing with just a regular Perl hash? (with the string being the key, and a global big int incremented as a unique value?)
  • Comment on Re^2: Algoritm for converting string to number?

Replies are listed 'Best First'.
Re^3: Algoritm for converting string to number?
by moritz (Cardinal) on Aug 23, 2011 at 13:10 UTC

      Okay, so not so simple, but I'd probably use...

      use Storable qw(store retrieve);

      and store and retrieve the hash once I was done with it, or needed it again.

      I'd also probably stuff the global value incrementor into some hash string and store it in the hash with a key value like, "Global Incrementing Hash Key Thingy".

      Of course Storable has its issues too...

        That has several downsides. One is that each time you add a single key, you have to write the whole data file.

        Another is that you have to deal with concurrent accesses yourself.

        And a third is that your data is lost if the program is killed while writing the file. D'oh.

        Better to use a ready-made, battle-tested solution like sqlite (or maybe berkeleydb) which deals with these problems for you.