如何在perl中加载下一个网页?

时间:2014-08-23 00:28:29

标签: html perl

我正在尝试使用perl学习Web开发。我有3个非常简单的perl脚本,只在每个页面上打印出一个文本行。我想要hello1.pl打印"你好世界"在浏览器中运行下一个脚本hello2.pl或hello3.pl,具体取决于$ rc值并在浏览器中加载该页面。我不认为我使用system命令做正确的事情。我该怎么做?

#!/usr/bin/perl

print "Content-type: text/html\n\n";
print <<PAGE;
<html>
<body>
hi to you too<br>
</body>
</html>
PAGE

hello3.pl

#!/usr/bin/perl

print "Content-type: text/html\n\n";
print <<PAGE
<html>
<body>
Good bye cruel world
</body>
</html>
PAGE

hello1.pl

#!/usr/bin/perl

print "Content-type:  text/html\n\n";

print <<PAGE;
<html>
<body>
hello world<br>
</body>
</html>
PAGE

$rc = 0;
if ($rc)
{
  system ("/Applications/XAMPP/htdocs/tutorial_perl/hello2.pl");
}
else
{
  system ("/Applications/XAMPP/htdocs/tutorial_perl/hello3.pl");
}

1 个答案:

答案 0 :(得分:2)

执行重定向的三种主要方法:

  1. 使用HTML标头:CGI - Generating a redirection header

  2. 使用META刷新:w3c - Using meta refresh to create an instant client-side redirect

  3. 使用JavaScript:Window Location

  4. 但是,老实说,您应该创建一个供用户点击的链接。

相关问题