You will need to serialize the structure in order to save it into the DB. There are many options available, each with advantages and disadvantages.
Data::Dumper is human-readable and serializes your structure as Perl code,
YAML is human-readable and cross platform (there are parsers for several languages). There is also
Storable, which is a binary format and is somewhat faster. And of course there are various XML things to choose from.