The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.

NAME

CGI - A module for programming CGI

SYNOPSIS

    use v6-alpha;
    use CGI;

    my $q = CGI.new;
    
    print $q.header;
    
    if ($q.param) {
        for $q.param -> $key {
            say $key ~ " => " ~ $q.param($key) ~ "<BR>";
        }
    }
    else {
        say "<FORM><INPUT TYPE='text' NAME='test'><INPUT TYPE='submit'></FORM>";
    }
    
    # you can also test it on the command line too
    % pugs -I lib/ examples/test.pl "greetings=hello world"    

DESCRIPTION

CGI for Perl6!

METHODS

Constructor

new()

Create a new object CGI object.

 my $q = CGI.new;

You can also initialize the object with your own hash of parameters:

 my $q = CGI.new( a => 'b');

Informational

param returns Array
param (Str $key) returns Array
query_string returns Str
request_method returns Str
content_type returns Str
content_length returns Str

The following informational functions are fetched on-demand

path_info returns Str
referer returns Str
request_uri returns Str
document_root returns Str
script_name returns Str

Utility

header (:$content_type = 'text/html', :$charset, :$location) returns Str
redirect (Str $location) returns Str
url_decode (Str $to_decode) returns Str
url_encode (Str $to_encode) returns Str
pack_params returns Str
unpack_params (Str $data) returns Str
as_yaml - Returns the query parameters as a YAML string.

Debugging

Dumping Out All the Name/Value pairs

The Dump method produces a string consisting of all the query's name/value pairs formatted nicely as a nested list. This is useful for debugging purposes:

    print $q.Dump;

Produces something that looks like:

    <ul>
        <li>name1
         <ul>
            <li>value1
            <li>value2
        </ul>
         <li>name2
            <ul>
                <li>value1
            </ul>
    </ul>

TO DO

Cookies

AUTHORS

stevan little, <stevan@iinteractive.com>

Audrey Tang, <autrijus@autrijus.com>

Curtis "Ovid" Poe

Andras Barthazi, <andras@barthazi.hu>

"Aankhen"

Mark Stosberg

COPYRIGHT

Parts Copyright (c) 2005. Stevan Little. All rights reserved. Parts Copyright (c) 2006. Mark Stosberg.

This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.

See http://www.perl.com/perl/misc/Artistic.html