For hobby purposes, I have a shared space on a hosting server that is providing, as many of them are, both PHP and Perl CGI. I have read on several places that CGI scripts
Here is a simple "hello world" example that runs under CGI using the Squatting web microframework:
use strict;
use warnings;
{
package MyApp;
use base 'Squatting';
use base 'Squatting::On::CGI';
}
{
package MyApp::Controllers;
use Squatting ':controllers';
our @C = (
C(
Index => [ '/' ],
get => sub {
my ( $self ) = @_;
my $v = $self->v;
$v->{say} = 'hello world!';
$self->render( 'hello' );
},
),
);
}
{
package MyApp::Views;
use Squatting ':views';
use HTML::AsSubs;
our @V = (
V( 'html',
layout => sub {
my ( $self, $v, @yield ) = @_;
html (
head ( title( 'My CGI App' ) ),
body ( @yield ),
)->as_HTML;
},
hello => sub {
my ( $self, $v ) = @_;
p ( $v->{say} );
},
),
);
}
use CGI;
my $q = CGI->new;
MyApp->init;
MyApp->relocate('/cgi-bin/myapp.cgi');
MyApp->cgi($q);
Save as "myapp.cgi" and place in your cgi-bin.