Re: FAQ 9.16 How do I decode a CGI form?
- From: "szr" <szrRE@xxxxxxxxxxxxxxx>
- Date: Mon, 23 Jun 2008 11:01:29 -0700
Ben Bullock wrote:
On Mon, 23 Jun 2008 06:03:04 -0700, PerlFAQ Server wrote:
Use the CGI.pm module that comes with Perl. It's quick, it's
easy, and it actually does quite a bit of work to ensure things
happen correctly. It handles GET, POST, and HEAD requests,
multipart forms, multivalued fields, query string and message
body combinations, and many other things you probably don't want
to think about.
Was this statement really written by someone who uses CGI.pm
regularly?
I have used it many time over the years and I can't say I've found any
instance where it doesn't do what it should. I've had not rpoblems with
it.
[...]
the CGI module automatically parses the
input and makes each value available through the "param()"
function.
Yeah but - how hard is it to parse the input without CGI.pm? Not very,
and then you have the advantage of having complete control, and not
having to deal with the vagaries of a crackpot module like CGI.pm.
What vagaries are you referring to, exactly?
use CGI qw(:standard);
my $total = param( 'price' ) + param( 'shipping' );
my @items = param( 'item' ); # multiple values, same
field name
If you want an object-oriented approach, CGI.pm can do that too.
But if you want to use JavaScript, CSS, or any encoding other than
ASCII, CGI.pm will make your life miserable. I've been there and done
that, and my experience has been that CGI.pm is a pain in the neck.
When did JavaScript or CSS become "encodings"? CSS is a style ***
language, that is either inlined into an x?html document or in an
external document referenced from an x?html document. JavaScript/JS is a
client side (and server side in the case of ASP) scripting language that
too can appear within or linked externally from an x?html document.
By encoding do you mean ContentType? such as text/css or
text/javascript? Even so, what exactly does that have to do with CGI.pm
or cgi in general?
Many people try to write their own decoder (or copy one from
another program) and then run into one of the many "gotchas" of
the task. It's much easier and less hassle to use CGI.pm.
I really doubt that. My experience of CGI.pm is that one ends up
having to use "here documents" instead of start_html and header, and
endless "decode" statements on everything returned from param, because
CGI.pm is too inflexible to allow you to do things correctly.
Could you please provide an example or two where you feel CGI.pm fell
short? I think this will better help myself and others to understand
where you are coming from, as everyone might have different experiences.
(Also, what's wrong with HEREDOCs? :-) )
--
szr
.
- Follow-Ups:
- Re: FAQ 9.16 How do I decode a CGI form?
- From: Hans Bulvai
- Re: FAQ 9.16 How do I decode a CGI form?
- References:
- FAQ 9.16 How do I decode a CGI form?
- From: PerlFAQ Server
- Re: FAQ 9.16 How do I decode a CGI form?
- From: Ben Bullock
- FAQ 9.16 How do I decode a CGI form?
- Prev by Date: Re: FAQ 8.26 Why doesn't open() return an error when a pipe open fails?
- Next by Date: Re: I hate CGI.pm
- Previous by thread: Re: FAQ 9.16 How do I decode a CGI form?
- Next by thread: Re: FAQ 9.16 How do I decode a CGI form?
- Index(es):