P.S. I originally sent this to just Mark Stosberg yesterday, and he
suggested I sent it to perl6-users for more exposure, so here it is,
To those of you working on (or wanting to use) the Perl 6 native CGI.pm,
Concerning the work you've been doing lately in getting the Perl 6
version of CGI.pm to function, I would like to strongly suggest that
you don't simply clone CGI.pm for Perl 5, but rather introduce some
(possibly but not necessarily backwards-incompatible) improvements in
the process, in particular to correct some stupid design issues.
Note that I will make these changes myself if someone else doesn't.
But since you're extensively working on CGI.pm now, I'm giving you
these strong suggestions early on so that you can incorporate them
using other design decisions of your own choosing (eg, different
1. ALWAYS gather all GET/query-string variables that exist,
regardless of whether this is a POST or GET query. The Perl 5
version currently discards any GET vars that are included in a POST
request and doesn't provide any workaround save to uncomment a code
line in CGI.pm itself.
Eg, say you want to submit a POST form to this url:
Stuff like that should just work, but for CGI.pm in Perl 5 it
doesn't. I have to parse the query string myself if I get a POST
request, to make that work, and its inane that Perl 5's CGI.pm
doesn't just work with it.
2. Keep 2 distinct sets of query parameters, one each for GET (query
string) and POST (HTTP body) variables, that are both initialized and
can be appropriately read from and updated. They must be separate
because it is legitimate to have variables with the same names in
both places that must be kept distinct.
Combining these is like combining cookie or session variable with
either; all 4 are distinct things. I suggest that all accessors for
these contain the words "http get var(s)" or "http post var(s)" in
them respectively. For backwards compatability, you could also keep
"param" named functions which accesses a union of the above and the
post ones take precedence in a name conflict. But the key thing is
it must be possible+easy to use them separately.
Practically every other web invironment's basic built-ins, including
ASP and PHP, correctly keep these separate, and its time for Perl's
basics to join them.
3. ALWAYS retain any multiple values for get and post vars. For
ease of use, your accessors could look like "http_post_var()" and
"http_post_var_multi()" etc, which fetch either just the first item
as a scalar or an array ref having all the items (even if just one)
4. Make UTF-8 the default HTTP response character encoding, and the
default declared charset for text/* MIME types, and explicitly
declare that this is what the charset is. The only time that output
should be anything else, even Latin-1, is if the programmer specifies
5. Similarly, default to trying to treat the HTTP request as UTF-8
if it doesn't specify a character encoding; fallback to Latin-1 only
if the text parts of the HTTP request don't look like valid UTF-8.
So CGI.pm for Perl 6 can resemble the Perl 5 version, but in no way
should we retain backwards designs just because that's they way they
were before. So keep all input information and standardize on
Thank you in advance.
-- Darren Duncan