As merlyn has pointed out, there isn't really a bug here, just some confusion about how to use the method. (Personally, I would consider this a documentation bug) The POD doesn't really say what it returns, just that...
This method sets and returns query components that use the application/x-www-form-urlencoded format. Key/value pairs are separated by "&" and the key is separated from the value with a "=" character.
It's easy to see how you could interpret that to mean that it returns a hash (which is what most people think of when they think of "pairs") ... but the truth is it accepts multiple key=>val pairs with the same key as input, and returns multiple key=>val pairs with the same key as output...
laptop:~> perl -l -w -MURI my $u = new URI(); $u->query_form('foo'=>'bar','foo'=>'baz'); print join ':', $u->query_form; __END__ foo:bar:foo:baz
...when you slurp the output into a hash, you are ignoring all but one pair with the same key. As I said, I would consider this a documentation bug, because I don't think the POD is very clear, but the method is doing what it says.
For future refrence, when I looked at the bug you filed, i noticed it was marked "Fixed in 1.22 added" .. so i took a look at the Changelog for that rev, which mentions the new addition of URI::QueryParam. Looking at the Docs for that module was very enlightening. Using it adds a lot of methods to URI objects that look closer to what you want...
laptop:~> perl -l -w -MURI -MURI::QueryParam my $u = new URI('http://perl.com/?a=b&foo=baz&c=d&foo=bar'); print join ', ', $u->query_param('foo'); __END__ baz, bar
In reply to Re: URI.pm bug or am i missing something?
by hossman
in thread URI.pm bug or am i missing something?
by jeffa
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |