Beefy Boxes and Bandwidth Generously Provided by pair Networks
Your skill will accomplish
what the force of many cannot
 
PerlMonks  

Re: CGI modules?

by Adrade (Pilgrim)
on Jan 28, 2006 at 20:40 UTC ( [id://526206]=note: print w/replies, xml ) Need Help??


in reply to CGI modules?

If cookie data is all you're looking for, you can use something like this - I pulled this from a package I wrote for something or another. This is by no means comprehensive, but I dont require anything more complicated than this.
sub proc_cookies { my $self = shift; my $raw_dough = $ENV{'HTTP_COOKIE'}; $raw_dough =~ s/; /=/gi; $self->{COOKIES} = {}; %{$self->{COOKIES}} = split(/=/,$raw_dough); $self->{PROCESSED} = 1; return 1; }
I tend to also favor a slightly modified version of the old cgi-lib, in favor of CGI.pm, but I still use the latter for dealing with file input.

I think that sometimes, its just easier, especially if your need is very limited, to sort of pull together your own subroutines to handle stuff.

Hope this helps,
  -Adam

--
By a scallop's forelocks!

Replies are listed 'Best First'.
Re^2: CGI modules?
by brian_d_foy (Abbot) on Jan 28, 2006 at 21:41 UTC

    That's a pretty broken cookie parser. See the code in CGI::Cookie to see the other things that you have to handle. It's much easier to use a module that handles it all correctly than type more and get less. :)

    --
    brian d foy <brian@stonehenge.com>
    Subscribe to The Perl Review
      I agree that its most definately not for complicated usage... it was put in place in a situation in which I didnt have to handle anything beyond one key that was being passed in... its given as a rudimentary example, and something that could suffice (as it does for me) in situations that require very basic parsing. I did notice the simplicity of %cookies = parse CGI::Cookie($ENV{COOKIE}); from CGI::Cookie, which seems quite lovely indeed. For whatever reason, I have a tendency to limit loading in modules when I don't really need all their features, and given the use for which this was constructed, I still probably wouldn't change it, however duely noting your very pleasant alternative for future applications.

      Thanks,
        -Adam

      --
      By a scallop's forelocks!

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://526206]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others examining the Monastery: (4)
As of 2024-04-24 03:03 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found