perl如何内嵌html

centuries 2003-02-09 10:45:37
我现在有一个html的网页代码,要将其改为perl程序,如果只是单纯在其第一行加上"#!../perl/bin/perl",并将文件后缀名改为.cgi,会出现错误提示"You don't have permission to access /test/index.cgi on this server."。换句话说:后缀名为.cgi的perl里如何包含html代码?谢谢。
...全文
55 9 打赏 收藏 转发到动态 举报
写回复
用AI写文章
9 条回复
切换为时间正序
请发表友善的回复…
发表回复
ceocio 2003-02-11
  • 打赏
  • 举报
回复
不行的话把你的地址给我看看,还有就是把不能显示的图片的地址给我看看,另外把图片名字改为小写。
ceocio 2003-02-11
  • 打赏
  • 举报
回复
用相对路径,最好做一个安装文件setup.cgi

在你的这个文件中:
require "setup.cgi";

然后这样调用:
<img src="$gif/top.gif">

setup.cgi文件中有这一行:
$gif='http://your url/resource'; #图片的URL路径

这样用相对路径应该可以了。
centuries 2003-02-11
  • 打赏
  • 举报
回复
谢谢ceocio。
加了以后果然可以,但里面的图片"resource/Top.gif"却不能显示,代码如下:

#!../perl/bin/perl
print "Content-type: text/html \n\n";
print <<eof;

<html>
<head>
<title>Top</title>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
</head>

<body bgcolor="#FFFFFF" text="#000000">

<table border=0 cellpadding=2 cellspacing=0 width=100% height=100%>
<tr>
<td><img src="resource/Top.gif" width=100% height=100%></td>
</tr>
</table>

</body>
</html>
eof

图片的属性为755,也正确地存在于相应的目录.
centuries 2003-02-10
  • 打赏
  • 举报
回复
楼上的,如何改为.pl,跟.cgi有差异吧。大家还有何高见?
ceocio 2003-02-10
  • 打赏
  • 举报
回复
sub html_html
{
print "Content-type: text/html\n\n";
print <<eof;
#这里输出html
eof
exit;
}
ceocio 2003-02-10
  • 打赏
  • 举报
回复
改为.pl也很方便
centuries 2003-02-10
  • 打赏
  • 举报
回复
还有,perl里
print <<"symbol";
之后还出现symbol
请问这是什么意思?
centuries 2003-02-10
  • 打赏
  • 举报
回复
谢谢楼上,但我要的是如何在perl里包含html,而不是如何在html里包含perl.不过还是谢谢了。
ceocio 2003-02-10
  • 打赏
  • 举报
回复
给你篇文章看看:

把程式語言嵌在 HTML 裡, 一直是許多網頁計者的夢想... 最近紅透半邊天的 PHP (讓 M$ 的 ASP 靠邊站), 成為廣大網站設計者的最愛(超過100萬個站台), 身為 Perl 的愛好者, 不禁要問: Perl 也可以嵌在 HTML 中嗎? 答案是: 可以的!

以下為您介紹三種不錯的 Embed Perl:

Mason - http://www.masonhq.com/

Embperl - http://perl.apache.org/embperl/index.html

ePerl - http://www.engelschall.com/sw/eperl/

首先, 您必須安裝好 Apache + mod_perl

Mason安裝法:

perl Makefile.PL
make
make install
修改 httpd.conf, 加入:

PerlRequire /usr/local/mason/handler.pl

Alias /mason /usr/local/www/htdocs

<location /mason>
 SetHandler perl-script
 PerlHandler HTML::Mason
</location>

重新啟動 Apache.
範例:
http://www.tnc.edu.tw/ml/TestMason.htm
http://www.tnc.edu.tw/ep/ePerl_test.htm
http://www.tnc.edu.tw/emp/embperl_test.htm

Embperl 及 ePerl 的安裝法類似,請自行參考程式包中的安裝說明.

2,204

社区成员

发帖
与我相关
我的任务
社区描述
Web 开发 CGI
社区管理员
  • CGI社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧