gpt4 book ai didi

html - 如何在 HTML 页面中调用 Perl 脚本?

转载 作者:行者123 更新时间:2023-11-28 04:42:32 28 4
gpt4 key购买 nike

我有一个 HTML 文件,如何在 HTML 代码中使用 Perl 脚本(日期/小时)?我的目标:在 HTML 中显示日期/小时观察:单独两个脚本都可以。

例子:HTML 文件:

<html>
<body>
code or foo.pl script
</body>
</html>

Perl 脚本(foo.pl):

#!/usr/local/bin/perl
use CGI qw/:push -nph/;
$| = 1;
print multipart_init(-boundary=>'----here we go!');
for (0 .. 4) {
print multipart_start(-type=>'text/plain'),
"The current time is ",scalar(localtime),"\n";
if ($_ < 4) {
print multipart_end;
} else {
print multipart_final;
}
sleep 1;
}

最佳答案

Perl 是一种服务器端语言,因此它必须在服务器上运行。 HTML 代码显示在浏览器中,由服务器生成。因此,您必须在服务器上运行 perl 脚本来生成日期/小时,并将其嵌入到您提供给浏览器的 HTML 代码中。

Here是关于如何执行此操作的教程。

关于html - 如何在 HTML 页面中调用 Perl 脚本?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3991085/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com