Beefy Boxes and Bandwidth Generously Provided by pair Networks
Clear questions and runnable code
get the best and fastest answer
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??
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?


In reply to CGI.pm: Want your query_string() sorted or unsorted? by markjugg

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others contemplating the Monastery: (6)
As of 2024-03-29 05:39 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found