in reply to Re: Store hash in mysql
in thread Store hash in mysql

I agree with Jeffa that in principle what you are asking to do sounds wrong. However, I don't know the circumstances and perhaps you need a temporary band-aid pending a better solution.

In that case, you have a couple of options:

  1. Use Data::Dumper to flatten the hash into a scalar (string) and store the latter in a TEXT (or suitably large CHAR/VARCHAR) column and use eval to turn it back into a hash.
  2. Create an array of key value pairs (eg using each %hash), join them with a special char and store that in the text column so a simple split on the resultant string will give you the key, value array back which you can easily turn back into a hash.