http://qs321.pair.com?node_id=1154747

dorko has asked for the wisdom of the Perl Monks concerning the following question:

Hello,

I'm looking to turn a Perl data structure into a CGI query string.

There are several modules that turn query strings into data structures (eg CGI::Struct and CGI::State), but I need to do the opposite.

I've got something like this:

%hash = ( 'name' => 'test name', 'file_ids' => [ 1, 2 ], 'sub' => { 'name' => 'foo', 'message' => 'bar' }, );

And I want to turn it into something like this:

name=test+name&file_ids[]=1&file_ids[]=2&sub[name]=foo&sub[message]=bar

Even "data structure ==> JSON ==> query string" would be ok too.

I'm not finding any modules that do what I'm looking for. Does something like this exist?

Cheers,

Brent

-- Yeah, I'm a Delt.