CGI-Easy
view release on metacpan or search on metacpan
NAME
CGI::Easy - simple and straightforward helpers to make CGI easy
VERSION
This document describes CGI::Easy version v2.0.1
SYNOPSIS
use CGI::Easy::Request;
use CGI::Easy::Headers;
use CGI::Easy::Session;
my $r = CGI::Easy::Request->new();
my $h = CGI::Easy::Headers->new();
my $sess = CGI::Easy::Session->new($r, $h);
# -- access basic GET request details
my $url = "$r->{scheme}://$r->{host}:$r->{port}$r->{path}";
my $param_name = $r->{GET}{name};
my @param_color = @{ $r->{GET}{'color[]'} };
my $cookie_some = $r->{cookie}{some};
# -- file upload
my $avatar_image = $r->{POST}{avatar};
my $avatar_filename = $r->{filename}{avatar};
my $avatar_mimetype = $r->{mimetype}{avatar};
# -- easy way to identify visitors and get data stored in cookies
my $session_id = $sess->{id};
my $tempcookie_x= $sess->{temp}{x};
my $permcookie_y= $sess->{perm}{y};
# -- set custom HTTP headers and cookies
$h->{Expires} = 'Sat, 01 Jan 2000 00:00:00 GMT';
$h->add_cookie({
name => 'some',
value => 'custom cookie',
domain => '.example.com',
expires => time+86400,
});
# -- easy way to store data in cookies
$sess->{temp}{x} = 'available until browser closes';
$sess->{perm}{y} = 'available for 1 year';
$sess->save();
# -- output all HTTP headers and html page
print $h->compose();
print "<html>...</html>";
# -- output redirect
$h->redirect('http://example.com/');
print $h->compose();
# -- output custom reply
$h->{Status} = '500 Internal Server Error';
$h->{'Content-Type'} = 'text/plain; charset=utf-8';
print $h->compose(), "Please try again later\n";
DESCRIPTION
This documentation is an overview of CGI::Easy::* modules. For detailed
information about corner cases and available features you should
consult corresponding module documentation: CGI::Easy::Request,
CGI::Easy::Headers, CGI::Easy::Session. If you wanna work with CGI/HTTP
on lower level, you can look at CGI::Easy::Util. There also some other
useful modules available separately: CGI::Easy::URLconf,
CGI::Easy::SendFile.
CGI::Easy designed to help you do what you want with CGI/HTTP without
forcing you to learn one more huge and complex API specific to some
module, or limiting you to do your tasks only in way provided by this
module. With CGI::Easy you got all you need in simple hashes, and
you're free to do anything you like with this data, because it's your
data.
CGI::Easy consist of three main parts:
CGI::Easy::Request object
This object actually is simple hash populated with all data related
to current CGI request - GET/POST parameters, cookies, url path, â¦
When you create this object with new(), current request will be
( run in 0.689 second using v1.01-cache-2.11-cpan-b16cb0d3907 )