macos Mac OSX 上的 Perl 位置
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/5877325/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Perl Location on Mac OSX
提问by fullOfQuestions
I'm beginning to write a simple Perl program on my Mac, and I understand that the first line needs to be the location of Perl itself, every example or tutorial I find tells me the first line should be:
我开始在我的 Mac 上编写一个简单的 Perl 程序,我知道第一行必须是 Perl 本身的位置,我找到的每个示例或教程都告诉我第一行应该是:
"#!/usr/bin/perl"
"#!/usr/bin/perl"
However, with that there, I attempt to run the file under localhost and I get this error:
但是,在那里,我尝试在 localhost 下运行该文件,但出现此错误:
Internal Server Error The server encountered an internal error or misconfiguration and was unable to complete your request. Please contact the server administrator, [email protected] and inform them of the time the error occurred, and anything you might have done that may have caused the error. More information about this error may be available in the server error log.
Internal Server Error 服务器遇到内部错误或配置错误,无法完成您的请求。请联系服务器管理员 [email protected] 并告知他们错误发生的时间,以及您可能执行的任何可能导致错误的操作。服务器错误日志中可能提供有关此错误的更多信息。
Anyone have any idea why this is happening?
任何人都知道为什么会这样?
Thanks in advance, and let me know if any more information is needed!
提前致谢,如果需要更多信息,请告诉我!
P.S. if it helps, when I execute the command: "perl -v" it tells me
PS如果有帮助,当我执行命令时:“perl -v”它告诉我
This is perl, v5.10.0 built for darwin-thread-multi-2level (with 2 registered patches, see perl -V for more detail)
这是 perl,为 darwin-thread-multi-2level 构建的 v5.10.0(有 2 个注册补丁,更多细节见 perl -V)
回答by Eric Seidel
As Erik said, /usr/bin/perl
is the standard location for Perl on OSX. You can also verify this by running which -a perl
from terminal (this will list all instances of Perl on your path).
正如 Erik 所说,/usr/bin/perl
是 OSX 上 Perl 的标准位置。您还可以通过which -a perl
从终端运行来验证这一点(这将列出您路径上的所有 Perl 实例)。
Can you run your script from the command-line, i.e. ./<myscript>.pl
? It's possible that you haven't made the script executable.
你能从命令行运行你的脚本./<myscript>.pl
吗?您可能没有使脚本可执行。
回答by Erik
#!/usr/bin/perl
is the correct path for 10.6. If you're running from the webserver, your first line before any output should be a HTML header. You may have forgotten one?
#!/usr/bin/perl
是 10.6 的正确路径。如果您从网络服务器运行,则任何输出之前的第一行应该是 HTML 标头。你可能忘记了一个?
#!/usr/bin/perl
use CGI;
print CGI->header('text/html');
print "hello world";