Replaces the standard functions that report fatal errors (die, croak, confess) and warnings (warn, carp, cluck) with ones that write out nicely time-stamped messages to the HTTP server error log.
The following functions are not exported by default. Placement in a BEGIN block is suggested.
function | returns | parameters |
---|---|---|
param | @ parameter names as a list | none |
@ or $: value(s) of parameter | $parameter | |
sets the value for the parameter to an array of values | [-name=>]$parameter, [-value[s]=>]@values | |
append | adds value(s) to the parameter | -name=>$parameter, -values=>@values |
url_param | parameters in URL created when a form specifies GET | none |
import_names | for each parameter, creates a variable in the namespace | $spacename |
delete | removes the parameter | $parameter |
delete_all | clears the CGI object completely | none |
param_fetch | an array reference to the parameter's values. | [-name=>]$parameter |
Vars | parameters as a tied hash reference ($ context) or a hash (% context) | none |
save | writes the current state of the form to the filehandle | FILEHANDLE |
self_url | a URL for this script with all its state information intact | none |
query_string | unprocessed query string | none |
url | URL with protocol, host, path, and port fields as specified | named arguments hash (see table below) |
-oldstyle_urls | separate name=value pairs with ampersands rather than semicolons | none |
Key | Parts of URL to return |
---|---|
-full | all fields (default) |
-relative | relative path only |
-absolute | absolute path only |
-path_info | path information appended |
-path | |
-query | query string appended |
-query_string | |
-base | only protocol, host, and port |
function | returns | parameters |
---|---|---|
-nph or nph(1) | produce a no-parsed header | none |
redirect | redirect browser to URL | [-uri=>]$uri, [-nph=>1] |
header | returns a header | type, status (or hash below) |
Key | Description of value (scalar) | Label |
---|---|---|
-type | media type (default is 'text/html') | Content-Type |
-status | status code and human-readable message (ex, '402 Payment required') | Status |
-nph | no-parse-header? (0|1) | ? |
-expires | absolute date/time or relative (now|{+|-}#{m|h|d|M|y}) interval | Expires, Date |
-cookie | cookie info | Set-Cookie |
-charset | character set (default is 'ISO-8859-1') (also sets charset() method) | charset= |
-anything | anything (internal underscores will be turned into hyphens) | same as key |
Code | Purpose | Parameter |
---|---|---|
-no_xhtml | don't use XHTML syntax | none |
use CGI::Pretty | produce nicely formatted HTML code | none |
local($") | character, if any, to put between elements | none |
charset | get $charset or set the current character set | [$charset] |
escapeHTML | get string with HTML format characters escaped | unescaped string |
Returns a canned HTML header and the opening body tag. All parameters are optional. The first three parameters listed here are the old-style positional parameters with any additional parameters included in the <body> tag. The recognized named parameters are as follows.
Key | Value | Tag | Attribute |
---|---|---|---|
-title | title | title | none |
-author | author's e-mail address | link | rev="made" |
-base | 'true' | base | none |
-xbase | uri | base | href |
-target | target frame for links | link | target |
-dtd | ? | !DOCTYPE | ? |
-lang | language code (default is 'en-US') | HTML | language |
-meta | reference to an associative array | meta | name, content |
-style | see below | style | see below |
-head | string, or array of strings | any | any |
-script | see below | script | see below |
-noScript | HTML when browser ignores scripts | noscript | none |
-other | hash array of attribute/value pairs | body | any |
The cascading stylesheet key (-style) values may be:
The Link function begins with an initial capital because of conflict with a built-in Perl function.
The -script key's values may be: