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

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...

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

    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.

      Heh. Funny. I've run into all these problems before, so yeah, I concede your point. Well said.

      Still, for prototyping... it sure is quick and dirty. :D