Perl CGI元标记
为了制作元标记,给出了以下示例: 但是,使用以下代码:Perl CGI元标记,perl,cgi,Perl,Cgi,为了制作元标记,给出了以下示例: 但是,使用以下代码: #!/usr/bin/perl use strict; use warnings; use CGI; my $cgi = new CGI; $cgi->autoEscape(undef); $cgi->html({-head=>meta({-http_equiv => 'Content-Type',-content => 'text/html',-charset=>'utf-8'}),-title=&g
#!/usr/bin/perl
use strict;
use warnings;
use CGI;
my $cgi = new CGI;
$cgi->autoEscape(undef);
$cgi->html({-head=>meta({-http_equiv => 'Content-Type',-content => 'text/html',-charset=>'utf-8'}),-title=>'Test'},$cgi->p('test'));
我得到以下错误:
$perl test.cgi未定义子例程
&main::meta在test.cgi第8行调用
我正在尝试生成以下标记:
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
使用CGI时,
元
子项不会自动导入代码>。试一试
use CGI "meta";
(或“:全部”
)
但是,您是否100%确定要在web开发中使用CGI,而不是更好的方法,如PSGI/Plack?这篇文章很老,但解决方案很简单:meta是对象$CGI的一种方法,所以将其用作方法 你的榜样
#!/usr/bin/perl
use strict;
use warnings;
use CGI;
my $cgi = new CGI;
$cgi->autoEscape(undef);
$cgi->html({-head=>$cgi->meta({-http_equiv => 'Content-Type',-content=>'text/html',-charset=>'utf-8'}),-title=>'Test'},$cgi->p('test'));
我只是在meta的fromt中添加了$cgi->。选择有限,我正在制作一个页面,以便在Netcool/Omnibus内部工作,它使用自己的Websphere HTTP服务器,它与Perl的配合效果最好。PSGI/Plack是Perl。;)但是,好吧,我不知道公共汽车。无论如何,如果Omnibus可以充当代理,这里应该没有问题,因为您只需将请求代理给Plack。Plack确实加快了perl web应用程序的开发速度。(0.02美元):)请停止使用肮脏的旧CGI.pm。请改用现代且干净的web引擎,如或。
#!/usr/bin/perl
use strict;
use warnings;
use CGI qw(:all);
my $cgi = new CGI;
$cgi->autoEscape(undef);
$cgi->charset('utf-8');
print
$cgi->start_html(
-head => meta({-http_equiv => 'Content-Type', -content => 'text/html'}),
-title => 'Test'
);
#!/usr/bin/perl
use strict;
use warnings;
use CGI;
my $cgi = new CGI;
$cgi->autoEscape(undef);
$cgi->html({-head=>$cgi->meta({-http_equiv => 'Content-Type',-content=>'text/html',-charset=>'utf-8'}),-title=>'Test'},$cgi->p('test'));