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

If you're fine with losing the mapping once the process terminates, sure.

  • Comment on Re^3: Algoritm for converting string to number?

Replies are listed 'Best First'.
Re^4: Algoritm for converting string to number?
by raybies (Chaplain) on Aug 23, 2011 at 13:26 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.

        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