perl作为一种语言和CGI脚本有什么区别?

perl作为一种语言和CGI脚本有什么区别?,第1张

概述我正在学习Perl并试图理解Perl和CGI之间的区别.我在 this website 发现了一些定义, “It is possible to set up the HTTP server so that whenever a file in a certain directory is requested that file is not sent back; instead it is exe 我正在学习Perl并试图理解Perl和CGI之间的区别.我在 this website 发现了一些定义,

“It is possible to set up the http server so that whenever a file
in a certain directory is requested that file is not sent back;
instead it is executed as a program,and whatever that program outputs
is sent back for your browser to display. This function is called the
Common Gateway Interface or CGI and the programs are called CGI
scripts.”

所以我的问题是,不仅CGI脚本将作为执行文件发送,所有其他服务器脚本语言将作为执行文件从http服务器发送.那么,CGI的主要目的是什么?

我非常想知道答案,因为我真的很困惑.这个问题可能是愚蠢的,但我需要知道答案.

例如:

#!/usr/bin/perlprint "Content-type:text/HTML\r\n\r\n";print '<HTML>';print '<head>';print '<Title>Hello Word - First CGI Program</Title>';print '</head>';print '<body>';print '<h2>Hello Word! This is my first CGI program</h2>';print '</body>';print '</HTML>';1;

如果我将它保存在.pl和.cgi扩展名并运行两个程序,我得到相同的输出.那么cgi脚本和perl之间有什么区别?

解决方法 CGI是标准方法或接口 – 即“ Common Gateway Interface” – 用于与Web服务器通信并为客户端请求动态生成网页的应用程序.

您的应用程序可能具有.cgi扩展名的事实主要取决于您的Web服务器配置.应用程序可以具有.PHP或.pl扩展名,并配置为使用CGI方法与Web服务器一起运行.虽然.cgi有点混淆了脚本编写的语言,但十多年来这种语言最常见于perl.实际上perl包含了CGI库,可以很容易地在perl中编写CGI应用程序.如果您从命令行而不是通过Web服务器运行应用程序,那么解释器将出现在* .cgi脚本中,如果是perl CGI应用程序,则类似于:#!/usr/local/bin / perl的.由于CGI相对简单,CGI应用程序已经用许多语言编写 – 即使是$SHELL脚本.

CGI在很大程度上被流程方法或用特定语言编写的完整http服务器应用程序堆栈(有时在代理服务器“后面”或“在Web服务器进程内”运行)所取代,主要是因为这些方法提供了改进的安全性和性能.在perl世界中,像Plack这样的应用程序框架是动态Web应用程序这种更现代化方法的一部分. Plack甚至包括Plack::App::WrapCGI,它可以“更新”您的CGI应用程序以在Plack框架内运行.

希望有所帮助.

总结

以上是内存溢出为你收集整理的perl作为一种语言和CGI脚本有什么区别?全部内容,希望文章能够帮你解决perl作为一种语言和CGI脚本有什么区别?所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址: https://outofmemory.cn/langs/1213064.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-06-04
下一篇 2022-06-04

发表评论

登录后才能评论

评论列表(0条)

保存