in reply to Perl array into MySQL Database

Could anyone tell me if it is possible to insert a perl array (or hash) into a mysql table?
no it isn't. what kind of mysql column type should it be?
one possibility, though, is to join the array together to a string and save that string. when reading it from the database you have to split it again to an array.

Replies are listed 'Best First'.
Re^2: Perl array into MySQL Database
by rsiedl (Friar) on Jul 21, 2004 at 11:30 UTC
    column type should be varchar.

    Yeah, thats what i currently do (join & split) but was curious if there was a "cleaner" way.

    cheers.
      As you allready know, you have to serialise your array. You do it with split and join and i think there are cleaner ways.
      Split uses regex, which isn't pretty fast.

      You could use Storable which is pretty fast, but produces binary file or DataDumper which produces text files.

      This solutions are also more general then using split & join, they also work for hashes, references (at least Storable).

      ciao
      knoebi