PSP::CGI - CGI class for the Perl Script Pages
use PSP::CGI; my $cgi = new PSP::CGI(); my $value = $cgi->param($key); my @values = $cgi->multiparam($key); my $param = $cgi->param(); my $value = $param->{$key}; my @keys = $cgi->params(); my $upload_item = $cgi->upload($key); my $upload = $cgi->upload(); my $upload_item = $upload->{$key}; my $filename = $upload_item->{filename}; my $size = $upload_item->{size}; my $content = $upload_item->{content}; my @keys = $cgi->uploads(); my $value = $cgi->cookie($key); my $cookie = $cgi->cookie(); my $value = $cookie->{$key}; my @keys = $cgi->cookies(); my $success = $cgi->setcookie($key, $value, $lifetime, domain => $domain, path => $path, secure => $bool ); $cgi->setheader( HeaderOne => 'foo', HeaderTwo => 'bar' ); my $text = $cgi->flushHeaders();
This module provides object oriented CGI capabilities for the Perl Script Pages (PSP) embedded Perl engine. See the PSP::Engine manpage for more information.
Reads GET and POST variables (CGI variables and file uploads) and Cookies, creates a new object of the PSP::CGI class.
use PSP::CGI; my $cgi = new PSP::CGI();
None.
None.
Returns either the value of a named CGI parameter or a reference to the internal parameter hash.
my $value = $cgi->param($key); my $param = $cgi->param(); my $value = $param->{$key};
If a requested parameter was transmitted twice or more (i.e. for a multi select input form), the values are returned separated by ASCII NUL (0x00) characters. You convert these parameters to an array as follows:
my @array = split(/\x00/, $cgi->param($keyOfMultiselectInput));
This is done automatically by the multiparam method. See below.
None.
Returns the values of a named CGI parameter as an array, allowing direct access to parameters that were transmitted twice or more (i.e. from form elements with ``multiple option'' set).
my @values = $cgi->multiparam($key);
None.
Returns an array of CGI parameter names supplied by the web browser.
my @keys = $cgi->params();
None.
None.
Returns either an upload item for a named HTTP upload or a reference to the internal uploads hash. Upload items are hashs containing more information about the upload, see syntax and $item description below.
my $item = $cgi->upload($key); my $upload = $cgi->upload(); my $item = $upload->{$key}; my $filename = $item->{filename}; my $size = $item->{size}; my $content = $item->{content};
None.
Returns an array of HTTP file upload names supplied by the web browser.
my @keys = $cgi->uploads();
None.
None.
Returns either the value of a named cookie or a reference to the internal cookies hash.
my $value = $cgi->cookie($key); my $cookie = $cgi->cookie(); my $value = $cookie->{$key};
None.
Returns an array of cookie names supplied by the web browser.
my @keys = $cgi->cookies();
None.
None.
Places a cookie of given name and value for a defined lifetime on the HTTP header queue. Defining domain, path or HTTPS restrictions is optional.
my $success = $cgi->setcookie($key, $value, $lifetime, domain => $domain, path => $path, secure => $bool );
The following parameters are hash key/value parameters.
Places one or more headers of given names and values on the HTTP header queue.
$cgi->setheader( HeaderOne => 'foo', HeaderTwo => 'bar' );
If the a header value contains \r or \n characters, everything beyond the first \r or \n will be removed. This prevents header injections.
The method accepts a hash of one or more HTTP headers and corresponding values. Existing headers of same name will be overwritten. See example above.
None.
None.
Returns the object's headers and cookie data in HTTP headers format and resets the data storage.
my $text = $cgi->flushHeaders();
None.
None.
Veit Wahlich
E-Mail: cru |at| zodia |dot| de
WWW: http://home.ircnet.de/cru/
v0.7 Wednesday, 18 January 2006
Copyright 2004-2006 Veit Wahlich
This software is distributed as free (libre) software under the terms of the GNU General Public License, version 2 <http://www.gnu.org/copyleft/gpl.html>. The author disclaims responsibility of any damage or harm caused directly or indirectly by usage of this software. Use only at your own risk.