NAME
Sordid::CGI - Rapid, Simple CGI application development
VERSION
Version 0.2
SYNOPSIS
Sordid::CGI can be used to create quick (and dirty) CGI applications. While I recommend the use of awesome frameworks that can use FastCGI, like Catalyst, sometimes you want to just write out some quick Perl code, instead of learning an entire framework. A working example of a simple query string.
#!/usr/bin/env perl
use warnings;
use strict;
# don't forget to import %_GET, %_POST or both depending on what you need
use Sordid::CGI qw( %_GET );
use HTML::JQuery;
my $webs = Sordid::CGI->new;
if (exists $_GET{name}) {
print "<p>Hello, " . $_GET{name} . "</p>\n";
}
else {
print "<p>Hi Anonymous!</p>\n";
}
Sordid::CGI->new
Creates a new instance of Sordid::CGI and also detects whether GET or POST has been submitted, then adds the values into %_GET and %_POST respectively.
stash
Pushes a variable into the stash to be used in a template.
$s->stash(title => 'My Page Title');
# template.tt
<title><% title %></title>
Sordid::CGI->redirect
Redirects the user to a different page. Redirects need to be done before the main html stuff (before start_html)
Sordid::CGI->redirect('/uri/to/redirect/to');
Sordid::CGI->url_decode
Turns all of the weird HTML characters into human readable stuff. This is automatically called when you get POST or GET data
Sordid::CGI->url_encode
This works the same as url_decode, except around the other way.
process
Processes a Template::Alloy template. Without any arguments the template will be <template_path>/<filename>.tt
# index.pl
use Sordid::CGI;
$s = Sordid::CGI->new(view => 'default.tt'); # layout will be <view_path>/default.tt
$s->process; # processes <template_path>/index.tt