perl如何内嵌html。
来源: 编辑:duliying 更新日期:2008-8-13 11:56:48 浏览:183 次
近日在CSDN的CGI版看到有centuries (燃烧太阳)网友问如何在Perl中内嵌HTML,这是在Perl WEB开发中经常遇到的一个问题,现在写出来,希望对大家有所帮助。
问 我现在有一个html的网页代码,要将其改为perl程序,如果只是单纯在其第一行加上"#!../perl/bin/perl",并将文件后缀名改为.cgi,会出现错误提示"You don‘t have permission to access /test/index.cgi on this server."。换句话说:后缀名为.cgi的perl里如何包含html代码?谢谢。
答 sub html_html
{
print "Content-type: text/html\n\n";
print <<eof;
#这里输出html
eof
exit;
}
问 谢谢ceocio。
加了以后果然可以,但里面的图片"resource/Top.gif"却不能显示,图片路径绝对是正确的,如:resource/top.gif
答 用相对路径,最好做一个安装文件setup.cgi
在你的这个文件中:
require "setup.cgi";
然后这样调用:
<img src="$gif/top.gif">
setup.cgi文件中有这一行:
$gif=‘http://your url/resource‘; #图片的URL路径,注意是单引号而不是双引号。
这样用相对路径应该可以了。
第1页/总1页
第一页 上一页
下一页 最后一页
【发表评论】