The code above only covers array and hashes of strings, and undef is not a string. Below is a variation that supports undef. Anything more complicated should definitely use FreezeThaw.
sub serialize_string_list { return join('|', map { (defined($_) ? do { local $_=$_; s/\^/^1/g; s/\|/^2/g; $_ } : '^0' ) } @_ ); } sub deserialize_string_list { return map { ($_ eq '^0' ? undef : do { local $_=$_; s/\^1/^/g; s/\^2/|/g; $_ } ) } split(/\|/, $_[0]); } $s = serialize_string_list(%test_hash); %test_hash = deserialize_string_list($s);
In reply to Re^3: Pass a hash as parameter to a CGI?
by ikegami
in thread Pass a hash as parameter to a CGI?
by C_T
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |