PC6下载站

分类分类

Windows下的Perl activeperl安装步骤

关注+2011-05-23作者:佚名

无论你是想在Windows操作系统学习Perl语言的核心功能,还是想了解下面这类面向Windows的Perl集成工具,你都必须从同一个地方开始,这就是在Windows上安装Perl。

1.下载并安装Perl-5.8-win32-bin.exe及近似版本;

2.安装apache 2.0以上版本

Apache HTTP Serverv2.0.55官方版5.8M6.6
下载

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
<Location /perl>
SetHandler perl-script
PerlHandler ModPerl::Registry
Options ExecCGI
allow from all
PerlSendHeader On
</Location>

此处"c:/perl/"为activeperl的安装目录,建议安装在盘符根目录下。

<!--[if !supportEmptyParas]--> <!--[endif]-->

然后重起apache,就可以在c:/perl目录下编写自己的perl CGI程序了。

<!--[if !supportEmptyParas]--> <!--[endif]-->
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 "<h1>";
print "hello,world!!";
print "</h1>";
print $query->end_html;
exit(0);
<!--[if !supportEmptyParas]--> <!--[endif]-->
<!--[if !supportEmptyParas]--> <!--[endif]-->

template模块windows环境下的安装及测试如下:

1.命令行安装:

ppm2 install http://theoryx5.uwinnipeg.ca/ppms/Apache-Template.ppd

或者使用ppm,(just test it!)

2.创建template.pl于c:/perl下:

<!--[if !supportEmptyParas]--> <!--[endif]-->
use Template;
<!--[if !supportEmptyParas]--> <!--[endif]-->
my ($type) = "text/html; charset=gbk";
print "Content-type: ", $type, "
";
<!--[if !supportEmptyParas]--> <!--[endif]-->
my $config = {
INCLUDE_PATH => 'C:/test',
EVAL_PERL  => 1,
};
<!--[if !supportEmptyParas]--> <!--[endif]-->
my $template = Template->new($config);
<!--[if !supportEmptyParas]--> <!--[endif]-->
my $replace = "要放入模板的變數";
my $vars = {
var => $replace,
};
<!--[if !supportEmptyParas]--> <!--[endif]-->
my $temp_file = 'template.html';
my $output;
$template->process($temp_file, $vars, $output)
|| die $template->error();
<!--[if !supportEmptyParas]--> <!--[endif]-->
print $output;
<!--[if !supportEmptyParas]--> <!--[endif]-->

创建template.html于c:/test下

<html>
<head>
<title>Arthur Dent: Greet the Planet</title>
</head>
<body>
dfsdf [% var %]
</body>
</html>
<!--[if !supportEmptyParas]--> <!--[endif]-->

这样我们就可以在浏览器中输入:http://localhost/perl/template.pl来测试我们的程序。

<!--[if !supportEmptyParas]--> <!--[endif]-->

<!--[if !supportEmptyParas]--> <!--[endif]-->

<!--[if !supportEmptyParas]--> <!--[endif]-->

<!--[if !supportEmptyParas]--> <!--[endif]-->

展开全部

相关文章

更多+相同厂商

热门推荐

  • 最新排行
  • 最热排行
  • 评分最高
排行榜

    点击查看更多

      点击查看更多

        点击查看更多

        说两句网友评论

          我要评论...
          取消