
EasyCGI - Perl CGI Interface

use EasyCGI;
if(defined(&EasyCGI::foo)){
print "lib is included";
}else{
print "lib is not included";
}
my $view=EasyCGI->new({
access => undef, # set true if u have own cgi interface
cgi_path => undef, # position of your own cgi interface
dba_path => undef, # position of database interface
cgi => undef, # cgi handler
dba => undef, # database handler
language => 'utf8', # language: un cn jp utf8, default is utf8
src_encoding => undef, # source code(.cgi) encoding, default is utf-8
web_encoding => undef, # web page encoding, default is utf-8
template_file_base_path => undef, # if null, use absolute file path
disable_cookie => 1 # disable for not support cookie, default is ''
});
############### TXT ################
# $view->set_return_type('txt');
#
# my $content='remote_addr: '.$view->remote_addr()."\n";
#
# $view->set_content($content);
####################################
############### HTML ################
# $view->set_return_type('html');
#
# my $content='<p>remote_addr: '.$view->remote_addr().'</p>';
#
# $view->set_content($content);
#####################################
############### REDIRECT ################
# $view->set_return_type('redirect');
#
# my $url='test.html';
#
# $view->set_url($url);
#########################################
############### FILE ################
# $view->set_return_type('file');
#
# my $file='test.txt';
#
# $view->set_file($file);
#####################################
print $view->output();
The synopsis above only lists the major methods and parameters.

if(defined(&EasyCGI::foo)){
print "lib is included";
}else{
print "lib is not included";
}
my $view=EasyCGI->new($rh_option);
$rh_option is a hash_ref has below option:
access : set true if u have own cgi interface
cgi_path : position of your own cgi interface
dba_path : position of database access
cgi : cgi handler
dba : database access
language : language: un cn jp utf8, default is utf8
src_encoding : source code(.cgi) encoding, default is utf-8
web_encoding : web page encoding, default is utf-8
template_file_base_path : if null, use absolute file path
disable_cookie : disable for not support cookie, default is ''
my $cgi = $view->cgi();
my $dba = $view->dba();
$view->set_dba($dba);
$view->lock();
$print $view->output();
#first look up in url param
#second look up in post param
#third look up in cookie param
my $id = $view->query_param('id');
my $id = $view->url_param('id');
#first look up in post param
#second look up in url param
my $id = $view->post_param('id');
my $id = $view->cookie_param('id');
my ($file_1, $file_2, $file_3) = $view->file();
my $file_1 = $view->file();
$view->push_cookie($cookie);
$cookie = $view->cookie();
$view->set_return_type('redirect');
$view->set_return_type('html', 'utf-8');
return type can be:
'redirect', 'txt', 'html', 'file'
if you set return type to 'txt' or 'html', you can have the second param for the web page encoding.
$view->set_tmpl_type('ht');
$view->set_tmpl_type('tt');
template type can be:
'ht'(default), 'tt'
$view->set_url($url);
you can set url only if the return type is 'redirect'
$view->set_content($content);
you can set content only if the return type is 'txt' or 'html', and have not set tmpl and tmpl_scalar
$view->set_tmpl($tmpl);
you can set tmpl only if the return type is 'txt' or 'html', and have not set content and tmpl_scalar
$view->set_tmpl_scalar($tmpl);
you can set tmpl_scalar only if the return type is 'txt' or 'html', and have not set content and tmpl
$view->set_tmpl_var($rh_tmpl_var);
you can set tmpl_var only if the return type is 'txt' or 'html', and have set tmpl or tmpl_scalar
$view->set_fill_var($rh_fill_var);
you can set fill_var only if the return type is 'txt' or 'html'
$view->set_fill_back($ra_keys);
you can set fill_back only if the return type is 'txt' or 'html'
$view->set_file($rh_file);
you can set file only if the return type is 'file'
my $rh=$view->session();
$rh_session = $view->session_create($rh);
$rh_session = $view->session_load($rh);
$view->session_save($rh);
$view->session_delete($rh);

The EasyCGI module is Copyright (c) 2003-2005 QIAN YU. All rights reserved.
You may distribute under the terms of either the GNU General Public License or the Artistic License, as specified in the Perl README file.