4.12. cgi

Returns the the current value of the named CGI input variable. HTML-escapes Interchange tags in the result for security.

Can also set a new CGI value within the current page.

4.12.1. Summary

    [cgi name]
    [cgi name=cgi_var_name other_named_attributes]
Parameters Description Default
name This is the name of the CGI variable whose value you want. None
Attributes Default
set none
hide No
filter none
keep (with filter) No
enable_html No
interpolate (reparse) No
Invalidates cache Yes

Tag expansion example:

Assuming CGI variable 'foo' = 'bar',

    [cgi foo]

ASP-like Perl call:

    $Tag->cgi( { name => var_name } );

    # or if you simply want the value:

    # or:

or similarly with positional parameters,

    $Tag->cgi($name, $attribute_hash_reference);

4.12.2. Description

Displays the value of a CGI variable submitted to the current page. This is similar to [value ...], except it displays the transitory values that have been submitted with the current request.

For instance, if you access the following URL:


bar will be substituted for [cgi foo].

This is the same as $CGI->{foo} in embedded Perl. name

This is the name of the CGI variable whose value you want. set

You can change a value with 'set=new_value'. The tag will return the CGI value you set unless you also set the hide=1 attribute.

Note that this is only available in new-style tags, for safety reasons. hide

Setting hide=1 suppresses the tag's return value, which can be useful with the set attribute. filter

See the filter tag for a list of filters.

Setting 'filter="filter"' modifies the named CGI variable with the specified filter. keep (with filter)

Set keep=1 if you want the tag to return a filtered result but do not want the filter to modify the CGI value itself in the $CGI::values hash. default

This sets a return value in case the named CGI variable is missing or otherwise false. The following will expand to "Using default":

    [cgi name=myname set=0 hide=1]
    [cgi name=myname default="Using default"] enable_html

Any '<' characters will normally be converted into '&lt;' for safety reasons. This conversion can be disabled using 'enable_html=1'.