ActivePerl for Windows是Windows环境下的Perl语言解释器,支持Microsoft IIS,包括Perl for Win32、Perl for ISAPI、PerlScript、Perl Package Manager四套程序。
软件介绍
ActivePerl一个可以让你任意执行 Perl 程序的工具软件,其包含了包括有 Perl for Win32、Perl for ISAPI、PerlScript、Perl Package Manager四套开发工具程序,可以让你编写出适用于 unix, windows, linux系统的CGI程序来。
安装的只是perl的一个解释程序啦,外观上也不会发生什么变化,你在windows的cmd界面里输入perl -v可查看你所安装的版本。在你编译perl程序时会用到它。若要编写perl程序需借助其它工具:notepad,eclipse.vim,eclim……用这些编写工具写好后存储成perl格式,就可用activeperl去编译喽!
安装教程
1.下载并安装Perl-5.8-win32-bin.exe及近似版本;
2.安装apache 2.0以上版本
3.通过命令行安装mod_perl,命令如下:
C:> ppm install http://theoryx5.uwinnipeg.ca/ppms/mod_perl.ppd
4,更改apache配置文件conf/ httpd.conf
在loadmodule处添加如下两行:
LoadFile "c:/perl/bin/perl58.dll"
LoadModule perl_module modules/mod_perl.so
在配置文件最后添加:
Alias /perl/ "c:/perl/"
PerlModule ModPerl::Registry
SetHandler perl-script
PerlHandler ModPerl::Registry
Options ExecCGI
allow from all
PerlSendHeader On
此处"c:/perl/"为activeperl的安装目录,建议安装在盘符根目录下。
然后重起apache,就可以在c:/perl目录下编写自己的perl CGI程序了。
E.g.:hello.pl
#!/usr/bin/perl
use strict;
use CGI;
my $query = new CGI;
print $query->header;
print $query->start_html(-title=>"show hello");
print "
";
print "hello,world!!";
print "
";
print $query->end_html;
exit(0);
template模块windows环境下的安装及测试如下:
1.命令行安装:
ppm2 install http://theoryx5.uwinnipeg.ca/ppms/Apache-Template.ppd
或者使用ppm,(just test it!)
2.创建template.pl于c:/perl下:
use Template;
my ($type) = "text/html; charset=gbk";
print "Content-type: ", $type, "
";
my $config = {
INCLUDE_PATH => 'C:/test',
EVAL_PERL=> 1,
};
my $template = Template->new($config);
my $replace = "要放入模板的變數";
my $vars = {
var=> $replace,
};
my $temp_file = 'template.html';
my $output;
$template->process($temp_file, $vars, $output)
|| die $template->error();
print $output;
创建template.html于c:/test下
dfsdf [% var %]
这样我们就可以在浏览器中输入:http://localhost/perl/template.pl来测试我们的程序。