View on
MetaCPAN
search.cpan.org is shutting down
For details read Perl NOC. After June 25th this page will redirect to MetaCPAN.org
Mischa POSLAWSKY > PLP > PLP::Fields

Download:
PLP-3.25.tar.gz

Dependencies

Annotate this POD

Website

CPAN RT

Open  1
View/Report Bugs
Module Version: 1.00   Source  

NAME ^

PLP::Fields - Special hashes for PLP

DESCRIPTION ^

For your convenience, PLP uses hashes to put things in. Some of these are tied hashes, so they contain a bit magic. For example, building the hash can be delayed until you actually use the hash.

%get and %post

These are built from the key=value&key=value (or key=value;key=value strings in query string and post content. %post is not built if the content type is not application/x-www-form-urlencoded. In post content, the semi-colon is not a valid separator.

%post isn't built until it is used, to speed up your script if you don't use it. Because POST content can only be read once, you can use CGI; and just never access %post to avoid its building.

With a query string of key=firstvalue&key=secondvalue, $get{key} will contain only secondvalue. You can access both elements by using the array reference $get{'@key'}, which will contain [ 'firstvalue', 'secondvalue' ].

%fields

This hash combines %get and %post, and triggers creation of %post. POST gets precedence over GET (note: not even the @-keys contain both values).

This hash is built on first use, just like %post.

%cookie, %cookies

This is built immediately, because cookies are usually short in length. Cookies are not automatically url-decoded.

%header, %headers

This is a hash of HTTP headers to accompany the first output. By default it will contain X-PLP-Version to identify the serving module, and Content-Type set to text/html.

If STDOUT has been opened as :utf8, a charset=utf-8 attribute will automatically be added. This will not be possible with FastCGI because FCGI (as of version 0.74) does not support output layers.

Headers can be added and/or changed as long as they have not yet been sent. Underscores in key names are converted to normal minus signs, so you can leave out quotes. The hash is case insensitive: the case used when sending the headers is the one you used first. The following are equal:

    $header{CONTENT_TYPE}
    $header{'Content-Type'}
    $header{Content_Type}
    $headers{CONTENT_type}

If a value contains newlines, the header is repeated for each line:

        $header{Allow} = "HEAD\nGET";  # equivalent to HEAD,GET

For example, to send out a non-HTML text instead of the default HTML:

    <:
    $header{content_type} = 'text/plain';
    use open ':std', ':utf8';
    :>
    This text should be prefixed by the following header:
        Content-Type: text/plain; charset=utf-8

AUTHOR ^

Juerd Waalboer <juerd@cpan.org>

Current maintainer: Mischa POSLAWSKY <shiar@cpan.org>

syntax highlighting: