header()
- Printing HTTP headers
GT::CGI - a lightweight replacement for CGI.pm
use GT::CGI; my $in = new GT::CGI; foreach my $param ($in->param) { print "VALUE: $param => ", $in->param($param), "\n"; }
use GT::CGI qw/-no_parse_buttons/;
GT::CGI is a lightweight replacement for CGI.pm. It implements most of the functionality of CGI.pm, with the main difference being that GT::CGI does not provide a function-based interface (with the exception of the escape/unescape functions, which can be called as either function or method), nor does it provide the HTML functionality provided by CGI.pm.
The primary motivation for this is to provide a CGI module that can be shipped with Gossamer products, not having to depend on a recent version of CGI.pm being installed on remote servers. The secondary motivation is to provide a module that loads and runs faster, thus speeding up Gossamer products.
Credit and thanks goes to the author of CGI.pm. A lot of the code (especially file upload) was taken from CGI.pm.
Can be called as either a class method or object method. When called with no arguments a list of keys is returned.
When called with a single argument in scalar context the first (and possibly only) value is returned. When called in list context an array of values is returned.
When called with two arguments, it sets the key-value pair.
header()
- Printing HTTP headersCan be called as a class method or object method. When called with no arguments, simply returns the HTTP header.
Other options include:
If called with a single argument, sets the Content-Type.
Returns a Location: header to redirect a user.
Sets or gets a cookie. To retrieve a cookie:
my $cookie = $cgi->cookie ('key'); my $cookie = $cgi->cookie (-name => 'key');
or to retrieve a hash of all cookies:
my $cookies = $cgi->cookie;
To set a cookie:
$c = $cgi->cookie (-name => 'foo', -value => 'bar')
You can also specify -expires for when the cookie should expire, -path for which path the cookie valid, -domain for which domain the cookie is valid, and -secure if the cookie is only valid for secure sites.
You would then set the cookie by passing it to the header function:
print $in->header ( -cookie => $c );
Returns the current URL of the script. It defaults to display just the script name and query string.
Options include:
This returns the current parameters as a hash. Any values that have the same key will be returned as an array reference of the multiple values.
Returns the passed in value URL escaped. Can be called as class method or object method.
Returns the passed in value URL un-escaped. Can be called as class method or object method. Optionally can take an array reference of strings instead of a string. If called in this method, the values of the array reference will be directly altered.
Returns the passed in value HTML escaped. Translates &, <, > and `` to their html equivalants.
Returns the passed in value HTML unescaped.
Note: GT::CGI depends on the GT::Base manpage and the GT::AutoLoader manpage, and if you are performing file uploads, GT::CGI::MultiPart, GT::CGI::Fh, and the GT::TempFile manpage. The ability to set cookies requires GT::CGI::Cookie.
Copyright (c) 2004 Gossamer Threads Inc. All Rights Reserved. http://www.gossamer-threads.com/
Revision: $Id: CGI.pm,v 1.145 2005/06/21 21:02:57 jagerman Exp $