是否存在不能在 CGI 中使用的 Perl 模块?

发布于 2024-07-09 20:24:58 字数 130 浏览 4 评论 0原文

我最近遇到一个问题,Tie::File 证明了我可以使用 Perl 程序的最佳答案。 我正准备使用 CGI,我需要问:是否有 Perl 模块不能在 CGI 中使用,尤其是 Tie::File? 如果有任何并发​​症,有什么方法可以调和它们吗?

I had a recent problem where Tie::File proved the best answer I could work with for a Perl program. I'm at a point where I'm ready to work with CGI, and I need to ask: are there Perl modules that can't be used in CGI, especially that Tie::File? If there are any complications, are there ways to reconcile them?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

娜些时光,永不杰束 2024-07-16 20:24:58

CGI 基本上只是一个在 STDIN 上读取请求并在 STDOUT 上喷出标头 + HTML 的程序。 它并不是很特别:如果你足够努力的话,没有任何模块是你不能使用的。

您甚至可以让图形化(例如 GTK)的工作变得足够痛苦。 不是你想要的。 除非您是第三方供应商,否则我对使其工作感到不满。

但请记住,程序的多个副本可能会同时运行(每个同时的 Web 请求一个),因此如果您使用平面文件,则必须处理锁定问题。

A CGI is basically just a program that reads a request on STDIN and spews header + HTML on STDOUT. It isn't really special: there aren't any modules you can't use, if you try hard enough.

You could even get graphical (e.g., GTK) ones working with enough pain. Not that you'd want to. Unless you're a third-party vendor I've had the displeasure of making that work for.

But remember that multiple copies of your program may be running simultaneously (one per simultaneous web request), so if you're using flat files, you'll have to deal with locking.

你另情深 2024-07-16 20:24:58

确保您的数据文件可由 CGI 进程读取和写入。 我添加这个答案是因为它导致了一个非常奇怪的错误。 我有一个无法从 CGI 运行的脚本。 事实上,CGI 可以很好地读取数据内容,但 Tie::File 失败了(即使我从命令行调用它,它工作得很好)。 事实证明,权限设置为 -rw-rw-r-- 这意味着世界可读,但只有我的用户和组可以写入它。 由于CGI进程没有写权限,Tie::File在CGI中失败。

Make sure your data file is readable and writable by your CGI process. I'm adding this answer because it led to a very odd bug. I had a script that wouldn't run from CGI. In fact the CGI could read the contents of the data just fine, but Tie::File failed (even though it worked fine if I called it from the command line). It turns out the permissions were set -rw-rw-r-- which means world-readable, but only my user and group could write to it. Since the CGI process didn't have write permissions, Tie::File failed in CGI.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文