BW::CGI - Simple OO CGI
use BW::CGI; my $o = BW::CGI->new;
Constructs a new BW::CGI object.
Returns a blessed BW::CGI object reference. Returns undef (VOID) if the object cannot be created.
Properties can be set by passing their values in a hash or hashref like this:
my $o = BW::CGI->new ( content_type => 'text/plain' );
Or by hashref, like this:
my $properties = { content_type => 'text/plain' }; my $o = BW::CGI->new ( $properties );
Returns the parsed results of the query string as a hashref, or undef.
Returns a list of query variable names. (q_names is an alias for qnames.)
Returns the value of the query variable name. If there is more than one variable with the same name a list will be returned, or if index is provided, the value in the specified list position. index is zero-based.
Returns a URI for use as a link back in the form action attribute.
Sets the HTTP "Status" code and, optionally, the associated message.
Sets a cookie. Must be called before headers are sent (see set_header). params is a hashref with the cookie parameters: name, value, expires, path, domain, secure, httponly.
Returns the value of the named cookie.
Clears the specified cookie from the browser by setting an empty cookie. The same parameter rules as in set_cookie apply.
Prints string to the client. Sends the headers first, if they haven't already been sent.
Sends an HTTP redirect (status code 302) to the client with Location set to destination.
Sets header key to value. Must be called before the first call to p (print) as the headers are sent to the client at that time.
Sends the headers that have been set with set_header.
Returns a header-ish date from a unix-epoch time value.
Returns an encoded copy of string with all non-matching /[^a-z0-9_\-\.,?:;\(\)\@! ]/ characters replaced with numeric HTML entities.
Returns an encoded copy of string with all non-matching /[^a-z0-9_]/ characters replaced with URL-encoded hexadecimal values (e.g., %20 for space).
Returns a URL-decoded copy of string.
Returns and clears the object error message.
Properties can be set or retrieved by using their name as a method, e.g.:
$o->content_type( 'text/plain' ); my $ct = $o->content_type;
The available properties for this method are:
The Content-type: header that gets sent to the client.
Content-type:
Value of HTTP_HOST environment variable. Used for creating links back to self, e.g., in the "action" attribute of form.
The maximum content length allowed from POST method queries. Defaults to 1MB (1,0485,776).
Written by Bill Weinman
Copyright (c) 1995-2008 The BearHeart Group, LLC
2009-11-04 bw -- added linkback method 2008-03-26 bw -- updated and documented 2007-10-20 bw -- initial release.
To install BW::CGI, copy and paste the appropriate command in to your terminal.
cpanm
cpanm BW::CGI
CPAN shell
perl -MCPAN -e shell install BW::CGI
For more information on module installation, please visit the detailed CPAN module installation guide.