CGI::WebIn - Perl extension for reading CGI form data
use CGI::WebOut; use CGI::WebIn(1);
# just to avoid "typo warning" our ($doGo,%Address,$Count);
# count visits SetCookie("Count",++$Count,"+10y");
# is the button pressed? if($doGo) { print "Hello from $Address{Russia}{Moscow}!"; }
print <<EOT; You have visited this page $Count times. <form action=$SCRIPT_NAME method=post enctype=multipart/form-data> <input type=text name="Address{Russia}{Moscow}" value="house"> <input type=submit name=doGo value="Say hello"> </form> EOT
This module is used to make CGI programmer's work more comfortable.
The main idea is to handle input stream (STDIN
) and QUERY_STRING
environment variable sent by browser and parse their correctly
(including multipart forms). Resulting variables are put to %GET
,
%POST
, %COOKIES
and %IN
(%IN
holds ALL the data). Also
allows you to get/set cookies (any structure, not only scalars!) with
SetCookie()
subroutine.
If this module is included without any arguments:
use CGI::WebIn;
it exports the following: %IN
, %GET
, %POST
, %COOKIES
,
SetCookie()
and DropCookie()
You can specify additional information to be exported by using include arguments:
use CGI::WebIn 'gpce';
means that all the GET, POST, Cookies and then environment
variables will be exported to ``usual'' package variables.
You must not be afraid to write everywhere 'gpce'
- the
following instruction does the same:
use CGI::WebIn 'gpce';
use CGI::WebIn(1)
%IN, %GET, %POST and %COOKIES
%IN
contains all the form data. %GET
, %POST
and %COOKIES
holds GET, POST and Cookies variables respectively.
void SetCookie($name, $value [,int $expire][,$path][,$domain][bool $secure])
%COOKIES
and ALL exported client modules immediately. Format for time $expire
can be
in any of the forms:
<stamp> - UNIX timestamp 0 - one-session cookie undef - drop this cookie "now" - expire immediately "+180s" - in 180 seconds "+2m" - in 2 minutes "+12h" - in 12 hours "+1d" - in 1 day "+3M" - in 3 months "+2y" - in 2 years "-3m" - 3 minutes ago(!)
void DropCookie(string $name [,string $path] [,string $domain])
$path
and $domain
parameters are
the same to previous SetCookie()
call.
file uploading support
.can_upload
:
# directory to upload user files dir = . # maximum allowed size of the file to upload maxsize = 100000
and place it to the current directory. If there is no .can_upload
file, uploading is disabled.
Dmitry Koteroff <koteroff@cpan.org>, http://www.dklab.ru
CGI::WebOut
.