perl-modperl mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Jeff Armstrong <modp...@aquabolt.com>
Subject Re: Apache2::Cookies - getting all names
Date Wed, 28 Dec 2005 18:43:47 GMT
-------- Original Message  --------
From: "Philip M. Gollucci" <pgollucci@p6m7g8.com>
To: Jeff <modperl@aquabolt.com>
Cc: mod_perl List <modperl@perl.apache.org>
Subject: Re:Apache2::Cookies - getting all names
Date: Wed Dec 28 2005 16:38:44

> Convesly, we could patch the code instead of the docs to make it do what 
> the docs said originally ?
> Index: Cookie.pm
> ===================================================================
> --- Cookie.pm   (revision 359541)
> +++ Cookie.pm   (working copy)
> @@ -40,7 +40,7 @@
>      my $jar = $req->jar or return;
>      $jar->cookie_class(__PACKAGE__);
>      return $jar->get(shift) if @_;
> -    return wantarray ? %$jar : $jar;
> +    return wantarray ? keys %$jar : $jar;
>  }
> 
> I'm betting the code change is what we want here.
> 

Oh lovely tied hashness :) I agree about the code change -  code posted 
by others shows that folks are coding round the bugette. Maybe what 
should really happen is:

my @names = $jar->names();
my @cookies = $jar->cookies();

Where the first returns the keys of %$jar and the second returns the 
values of %$jar. Unfortunately, this is not backwardly compatible :( - 
so how about something like:

my @names     = $jar->cookies();      # just the names
my @cookies   = $jar->all_cookies();  # all the cookies ie value %$jar
my @allnames  = $jar->all_names();    # all the names ie keys %$jar

and deprecate wantarray $jar->cookies() in favour of $jar->all_names()? 
I personally don't like that the return value of $jar->cookies() is 
sometimes cookie[s] and sometimes names and sometimes the jar itself.

In fact, the all_cookies() is what I really really want :) and have 
ended up coding. I want to know if I am suffering multi-same-named cookies!

Regards,
Jeff





Mime
View raw message