perl w/website中的get函数在perl脚本中不产生值
我试图获取index.pl?home=home以在perl脚本中生成值'home',或者home=anything以生成'anything' 由于某些原因,我没有正确使用GET方法perl w/website中的get函数在perl脚本中不产生值,perl,web,null,get,Perl,Web,Null,Get,我试图获取index.pl?home=home以在perl脚本中生成值'home',或者home=anything以生成'anything' 由于某些原因,我没有正确使用GET方法 #!/usr/local/bin/perl use CGI qw(:standard); $cgi = new CGI; $home = $cgi->param('home'); 我做错了什么?我一直在搜索这个特定的答案…你的代码对我来说很好。我的完整脚本如下所示: #!C:/perl/bin/perl.e
#!/usr/local/bin/perl
use CGI qw(:standard);
$cgi = new CGI;
$home = $cgi->param('home');
我做错了什么?我一直在搜索这个特定的答案…你的代码对我来说很好。我的完整脚本如下所示:
#!C:/perl/bin/perl.exe
use CGI qw(:standard);
$cgi = new CGI;
$home = $cgi->param('home');
print "Content-Type: text/plain\n";
print "\n";
print "Hello world\n";
print "Hello $home world\n";
(我在Windows上,但这不重要。)
当我访问http://localhost/stack.pl?home=xx
我明白了:
Hello world
Hello xx world
添加$cgi->header()代码>添加到脚本中。您很可能遇到了“脚本头过早结束
”错误:
查看您的错误日志以了解详细信息。这正是我的想法,与我试图做的几乎相同。。。但出于某种原因,它显示为空白值。好了,现在它工作正常,我在两者之间删除了一个额外的value=value2链接,这是导致错误的原因!!!
#!/usr/local/bin/perl
use CGI qw(:standard);
$cgi = new CGI;
$home = $cgi->param('home');
print $cgi->header();
print $home