use CGI::Minimal;
my $cgi = CGI::Minimal->new; if ($cgi->truncated) { &scream_about_bad_form; exit; } my ($form_field_value) = $cgi->param('some_field_name');
Rather than attempt to address every possible need of a CGI programmer, it provides the _minimum_ functions needed for CGI such as form decoding (including file upload forms), URL encoding and decoding, HTTP usable date generation (RFC1123 compliant dates) and _basic_ escaping and unescaping of HTMLized text.
The form decoding interface is somewhat compatible with the CGI.pm module. No provision is made for generating HTTP or HTML on your behalf - you are expected to be conversant with how to put together any HTML or HTTP you need.
Example:
use CGI::Minimal;
my $cgi = CGI::Minimal->new;
$cgi->param();
it returns the list of all defined form fields in the same order they
appear in the data from the user agent.
Called as $cgi->param($fieldname);
it returns the value (or array of values for multiple occurances of the
same field name) assigned to that $fieldname. If there is more than one
value, the values are returned in the same order they appeared in the data
from user agent.
Examples:
my (@form_fields) = $cgi->param;
my (@multi_pick_field) = $cgi->param('pick_field_name');
my ($form_field_value) = $cgi->param('some_field_name');
$cgi->param_mime();
it returns the list of all defined form fields in the same order they
appear in the data from the user agent.
Called as $cgi->param_mime($fieldname);
it returns the MIME type (or array of MIME types for multiple occurances of
the same field name) assigned to that $fieldname. If there is more than one
value, the values are returned in the same order they appeared in the data
from user agent.
This is only meaningful when doing Form Based File Uploads and should probably not be trusted even then since it depends on the _browser_ correctly identifying what it is sending.
$cgi->param_filename();
it returns the list of all defined form fields in the same order they
appear in the data from the user agent.
Called as $cgi->param_filename($fieldname);
it returns the file name (or array of file names for multiple occurances of
the same field name) assigned to that $fieldname. If there is more than one
value, the values are returned in the same order they appeared in the data
from user agent.
This is only meaningful when doing Form Based File Uploads.
Example:
print "Expires: ",$cgi->date_rfc1123(time + 3600),"\015\012";
Example:
print $cgi->calling_parms_table;
%xx
form)
Example:
my $url_encoded_string = $cgi->url_encode($string);
Example:
my $url_decoded_string = $cgi->url_decode($string);
Example:
my $html_escaped_string = $cgi->htmlize($string);
Returns '0' if the form was NOT truncated.
Example:
use CGI::Minimal;
my $cgi = CGI::Minimal->new; if ($cgi->truncated) { &bad_form_upload; } else { &good_form_upload; }
'truncated' will also return '1' if the form length received would have exceeded the set 'max_read_length'.
Example:
use CGI::Minimal;
CGI::Minimal::max_read_size(400000); my $cgi = CGI::Minimal->new;
Copyright (c) Benjamin Franz 1999. All rights reserved.
This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.