At 08:43 2002-09-03 -0700, Gisle Aas wrote:
>Some have suggested that $u->query_form should just split on both
>[&;]. I have two problems with that; 1) I'm not totally convinced
>that URIs like ?foo=1;2;3&bar=1 does not exist and 2) how do we know
>what to use for joining parameters.
Personally, I think the W3C's whole ;-for-& idea is something that should
have been done from the beginning, but which it's maybe too late to do now
-- since one never knows if a given server/CGI will be able to make sense
of ;-as-separator, I can't imagine any user-agent just spontaneously
emitting them, so I wonder if there will ever be impetus for adopting it.
So in the end, I have to suspect that it's just another bit of lunatic
babble like often comes out of the W3C. Not that the W3C is exactly alone
on this: ISO standards often seem to be issued from madhouses (which is
only fitting, considering that they often end up sending their readers to
the madhouse).
>Since $u->query_form currently must take an even number of arguments
>we could let it discover when passed an odd number of arguments and
>then shift (or pop) off one of them and use that as the separator.
>
> @semi_split = $u->query_form(";")
> $u->query_form(";", a => 1, b => 2);
What I often do in such cases of wanting to squeeze things into an existing
calling interface, is something like:
@semi_split = $u->query_form(\";")
$u->query_form(\";", a => 1, b => 2);
It's not terribly clever, and not very tidy, and obviously only works if
the methods in question couldn't ever have sensibly taken a scalar ref as
an argument. But it does come out pretty concise. A variant in something
like this:
@semi_split = $u->query_form([";"])
$u->query_form([";"], a => 1, b => 2);
I'm not really recommending it for this situation, but thought I'd mention
the general trick, is case anyone could use this sort of thing for their
own interfaces.
--
Sean M. Burke http://www.spinn.net/~sburke/