http://www.perlmonks.org?node_id=788093

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

I have a patch pending for CGI.pm that I'd like peer feedback on. The code change is dead simple, it's the conceptual change itself I'd like feedback on.

Currently, the query_string() method returns $ENV{QUERY_STRING} more or less how it received it, although it always processes and rebuilds the query string internally, so it's possible it's different. One change it will make is to convert the joining character to either "&" or ";", as you prefer.

My patch would cause a further change: it would cause the keys to be returned in a sorted order.

In support this of this change, it "canonicalizes" query strings, so that you can easily compare to queries to see if they have equivalent names and values, even if they are in a different order, or use a different joiner.

Without this change, the comparison would be much harder, you'd have to do something like turning the query back into a hash, then compare two hashes for equality.

On the other hand, you could speak against the change: For one, it's a change that could be considered unnecessary, and somebody, somewhere likely depends on the old behavior.

I tried to find a RFC which spoke to the point, but I couldn't find anything useful.

Although I have already submitted the patch, I'm having second thoughts about how as a "safe" change. There are other alternatives to make query comparison easier, such as a providing a "sorted_query_string()" method that would either directly in CGI.pm, or accessible through a plugin.

What do you think?