in reply to Saving and restoring hash variable data

$rd is the record delimiter and $fd the field delimiter. Both must not be found in either keys or strings. I've used \n and \t for simplicity, but special characters or character sequences are probably smarter.
my $rd = "\n"; my $fd = "\t"; my %db; $db{worda}[0] = "stringa"; $db{worda}[1] = "stringb"; $db{worda}[2] = "stringc"; $db{wordb}[0] = "stringd"; $db{wordb}[1] = "stringe"; $db{wordc}[0] = "stringf"; $db{wordd}[0] = "stringg"; $db{worde}[1] = "stringh"; $db{worde}[2] = "stringi"; $db{worde}[3] = "stringj"; for (keys %db) { print join $fd, $_, @{$db{$_}}; print $rd; }
And to reverse the generated data:
my $rd = "\n"; my $fd = "\t"; my (%db, $p, $i); $/ = $rd; while (<DATA>) { chomp; ($_, @_) = split $fd; $db{$_} = [@_]; } for (sort keys %db) { $p = $db{$_}; for ($i = 0; $i <= $#$p; $i++) { print "\$db{$_}[$i] = \"$p->[$i]\";\n"; } } __DATA__ wordc stringf wordd stringg worde stringh stringi stringj worda stringa stringb stringc wordb stringd stringe