* Philip Newton ([EMAIL PROTECTED]) [28 Sep 2000 21:19]:
> On 27 Sep 2000, at 23:48, iain truskett wrote:
> > So surely you'd want %HTTP (the input headers) to also be an array
> > rather than a hash, since they'd be required in order as well?
> I don't care, because I don't work with this much.
It's a case of: if you're going to have the output order, then you
should provide for the input to be ordered. *As well as* unordered.
> And I don't know whether I'd need to bear in mind the protocol which
> requires the order; I'd probably want to access them randomly. But
> that I send out has to follow the protocol.
A future protocol could well require things in order. Hence you're
having the output headers in order. Therefore you should have the input
ones available in order as well.
I'm thinking a $headers_in and a $headers_out type thing is needed where
things are a Headers object that can either return a given header
my $type = $headers_in->value('Content-Type');
or process things sequentially
foreach my $header_key ($headers_in->keys)
{
}
and of course add and remove things
while ($headers_in->keys)
{
my $headerline = $headers_in->shift;
my ($key, $value) = ($headerline->key, $headerline->value);
}
$headers_in->add('Breakfast-Food', 'Bagel');
and so on.
Flexible. Transparent. You could even tie things if you want, so things
are slightly more transparent. Combine operator overloading with some of
Damian's 'want' and Quantum::Superpositions stuff and things become
rather interesting.
Having a %HTTP and a @HEADERS is rather simplistic and not really that
accommodating for potential modifications to the protocols for HTTP and
CGI.
> In other words, the input has an order (the order in which the user-
> agent sent the headers), but I'm not necessarily interested in it
> (frequent CGI programmers may have different needs);
Precisely. So theoretically, we should provide for both situations.
> the output also has an order, and *someone* has to provide for that
> order, and I believe it is not good for Perl to do so (for the reasons
> given before).
I would agree.
cheers,
--
iain truskett, aka Koschei. <http://eh.org/~koschei/>
You know you are addicted to coffee if...
2 You sleep with your eyes open.