Javascript 在加载html页面上运行perl脚本

Javascript 在加载html页面上运行perl脚本,javascript,html,perl,Javascript,Html,Perl,如何在浏览器上加载html页面时运行perl脚本。我试着运行perlscript onload(),甚至在头上写下它。但没有起作用 perl脚本: #!/usr/bin/perl -w use strict; use CGI ':standard'; use warnings; use FileHandle; my $result="sakshi"; open(OUT,'>/var/cgi-bin/sample.html'); print OUT header(), start_h

如何在浏览器上加载html页面时运行perl脚本。我试着运行perlscript onload(),甚至在头上写下它。但没有起作用 perl脚本:

#!/usr/bin/perl -w
use strict;
use CGI ':standard';
use warnings;
use FileHandle;

my $result="sakshi";

open(OUT,'>/var/cgi-bin/sample.html');
print 
 OUT header(),
start_html(
    -title   => 'Command',
  -text    => '#520063'
);
print OUT "Hello $result";
print OUT end_html();
close(OUT);
我在html中尝试过的东西:

一,


测试
二,

HTML文件中的

<html>
  <head>
    <title></title>
    <script type="text/javascript" src="http://localhost/cgi-bin/my_script.pl"></script>
  </head>
  <body></body>
</html>
激活HTML文件时,/var/www/cgi-bin/sample.HTML文件现在将包含生成的内容:

<!DOCTYPE html
  PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
   "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="en-US" xml:lang="en-US">
<head>
<title>Command</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
</head>
<body text="#520063">
1
</body>
</html>

命令
1

希望这能让事情变得明朗一点

你想完成什么?发布的代码没有任何意义。是的,它确实有效,但这取决于你实际上不想发生什么?或者您是否遇到内部服务器错误?如果是,请从错误日志中发布错误消息。
<html>
  <head>
    <title></title>
    <script type="text/javascript" src="http://localhost/cgi-bin/my_script.pl"></script>
  </head>
  <body></body>
</html>
#!/usr/bin/perl

use strict;
use CGI ':standard';
use warnings;
use FileHandle;

my $result="sakshi";

open(OUT, ">", "/var/www/cgi-bin/sample.html") or die "cannot open > /var/www/cgi-bin/sample.html: $!";
print OUT header();
print OUT start_html(-title=>'Command',-text=>'#520063');
print OUT print("Hello $result");
print OUT end_html();
close(OUT);
<!DOCTYPE html
  PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
   "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="en-US" xml:lang="en-US">
<head>
<title>Command</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
</head>
<body text="#520063">
1
</body>
</html>