CGI::Minimal and Cookies

CGI::Minimal and Cookies

am 18.12.2007 00:06:38 von John Bokma

From the documentation of CGI::Minimal: "See 'CGI::Cookie' for cookie
generation". Which sounds like a lot of fun, except that CGI::Cookie does:

use CGI;

Which probably makes use CGI::Minimal pointless. Or am I wrong?

How to use Cookies (reading/setting) with CGI::Minimal? I couldn't find a
CGI::Minimal::Cookie module :-( (There is a "thin" module, but a peek at
the code made me shudder...)

--
John

Re: CGI::Minimal and Cookies

am 18.12.2007 01:41:46 von Ben Morrow

Quoth John Bokma :
> From the documentation of CGI::Minimal: "See 'CGI::Cookie' for cookie
> generation". Which sounds like a lot of fun, except that CGI::Cookie does:
>
> use CGI;
>
> Which probably makes use CGI::Minimal pointless. Or am I wrong?

Which version? I have 1.26 here, and it doesn't use CGI. It does use
CGI::Util, which contains a group of routines for doing URI-escaping and
such; maybe older versions just used CGI instead, and the code's been
refactored?

Ben

Re: CGI::Minimal and Cookies

am 18.12.2007 02:33:04 von xhoster

Ben Morrow wrote:
> Quoth John Bokma :
> > From the documentation of CGI::Minimal: "See 'CGI::Cookie' for cookie
> > generation". Which sounds like a lot of fun, except that CGI::Cookie
> > does:
> >
> > use CGI;
> >
> > Which probably makes use CGI::Minimal pointless. Or am I wrong?
>
> Which version? I have 1.26 here, and it doesn't use CGI. It does use
> CGI::Util, which contains a group of routines for doing URI-escaping and
> such; maybe older versions just used CGI instead, and the code's been
> refactored?


I see it there, in the next line after the use CGI::Util. Maybe you
deleted use CGI in your local copy? After a quick look through the code, I
expect it would work to omit that line.

http://search.cpan.org/src/LDS/CGI.pm-3.16/CGI/Cookie.pm

$CGI::Cookie::VERSION='1.26';

use CGI::Util qw(rearrange unescape escape);
use CGI;
use overload '""' => \&as_string,
'cmp' => \&compare,
'fallback'=>1;




Xho

--
-------------------- http://NewsReader.Com/ --------------------
The costs of publication of this article were defrayed in part by the
payment of page charges. This article must therefore be hereby marked
advertisement in accordance with 18 U.S.C. Section 1734 solely to indicate
this fact.

Re: CGI::Minimal and Cookies

am 19.12.2007 20:32:03 von Charles DeRykus

On Dec 18, 10:58 am, Ben Morrow wrote:
....

> > Unfortunately you can't prevent a "use" from happening via subclassing.
>
> {
> local $INC{'CGI.pm'} = $0;
> use CGI::Cookie;
> }
>


Wouldn't that need a BEGIN {} tweak since
'use CGI::Cookie' loads earlier ... ?


> perhaps with a
>
> {
> package CGI;
> use autouse CGI => 'header';
> }
>
> as well. Of course, it will break if you call the ->bake method, so
> don't do that.


--
Charles DeRykus

Re: CGI::Minimal and Cookies

am 19.12.2007 20:36:52 von Ben Morrow

Quoth "comp.llang.perl.moderated" :
> On Dec 18, 10:58 am, Ben Morrow wrote:
> > [Xho wrote:]
> >
> > > Unfortunately you can't prevent a "use" from happening via subclassing.
> >
> > {
> > local $INC{'CGI.pm'} = $0;
> > use CGI::Cookie;
> > }
>
>
> Wouldn't that need a BEGIN {} tweak since
> 'use CGI::Cookie' loads earlier ... ?

Yes, of course. My mistake... :) To still achieve the 'local', it would
need to be

BEGIN {
local $INC{'CGI.pm'} = $0;
require CGI::Cookie;
CGI::Cookie->import(...);
}

Ben