如何在 Perl CGI 脚本中使用 google API?
google API 示例显示您应该在 head 标记中包含 javascript,但我使用的是 perl 模块 CGI,并且在那里他们建议您使用“print header;”而不是明确地写出标题。
那么,如果我想使用 perl CGI 模块和 google API javascript,正确的方法是什么?
我尝试明确地写出标头,但似乎 perl 模块确实希望我使用标头方法。这似乎是一个常见的用例,但我在网上查找了一些示例,但找不到。任何帮助将不胜感激。
The google API example shows that you should have the javascript within the head tag but I am using perl module CGI and in there they suggest that you use "print header;" instead of writting out your headers explicitly.
So if I want to use the perl CGI module and the google API javascript what is the correct way to do this?
I tried writing out the header explicitly but It seemed like the perl module really wanted me to use the header method. It seems like this would be a common use case but I looked around the web for some examples of this and I could not find one. Any help would be appreciated.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
只需忽略 CGI 文档并使用
部分打印您自己的 HTML 头部分。
顺便说一句,CGI 中的
header
函数打印 HTTP 标头,而不是 HTML 标头。 html 标头由函数生成start_html
。但你不需要使用CGI的内置函数。 CGI 输出应该如下所示(没有 # 部分):Just ignore the CGI documentation and print your own HTML head section with the
<script>
section.By the way, the
header
function in CGI prints the HTTP header, not the HTML header. The html header is produced by a functionstart_html
. But you do not need to use CGI's built-in function. CGI output is supposed to look like the following (without the # parts):