为什么我无法从 TextMate 运行 Perl 程序?
我正在阅读一本生物信息学文本,这代表了我的第一个 Perl 脚本。而在 TextMate 中,这不会产生任何结果。功能正常吗?我在底部添加了“hello world”,但当我在 TextMate 中运行脚本时没有看到这一点。我做错了什么?
#!/usr/local/bin/perl -w
use lib "/Users/fogonthedowns/myperllib";
use LWP::Simple;
use strict;
#Set base URL for all eutils
my $utils = "http://eutils.ncbi.nlm.nih.gov/entrez/eutils";
my $db = "Pubmed";
my $query ="Cancer+Prostate";
my $retmax = 10;
my $esearch = "$utils/esearch.fcgi?" .
"db=$db&retmax=$retmax&term=";
my $esearch_result = get($esearch.$query);
print "ESEARCH RESULT: $esearch_result\n";
print "Using Query: \n$esearch$query\n";
print "hello world\n";
I'm following a bioinformatics text, and this represents one of my first Perl scripts. While in TextMate, this does not produce any result. Is it functioning? I added "hello world" at the bottom and I don't see that when I run the script in TextMate. What have I done wrong?
#!/usr/local/bin/perl -w
use lib "/Users/fogonthedowns/myperllib";
use LWP::Simple;
use strict;
#Set base URL for all eutils
my $utils = "http://eutils.ncbi.nlm.nih.gov/entrez/eutils";
my $db = "Pubmed";
my $query ="Cancer+Prostate";
my $retmax = 10;
my $esearch = "$utils/esearch.fcgi?" .
"db=$db&retmax=$retmax&term=";
my $esearch_result = get($esearch.$query);
print "ESEARCH RESULT: $esearch_result\n";
print "Using Query: \n$esearch$query\n";
print "hello world\n";
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
您在 TextMate 中成功运行过其他脚本吗?我怀疑您有编辑器配置问题(或者 URL 不可命中且脚本生成错误)。
尝试运行一个更简单的脚本,看看会发生什么,例如:
接下来,看看是否可以看到错误输出:
Have you run other scripts successfully in TextMate? I suspect that you have an editor configuration issue (or that URL is not hittable and the script is generating an error).
Try running an even simpler script and see what happens, e.g. something like:
Next, see if you can see error output:
最有可能的是,您的执行环境没有以正确的方式设置,即 TextMate 不知道如何执行 Perl 脚本并向您显示结果。您是否尝试过从 shell 运行它?
Most likely, your executing environment is not set up in the right way, i.e., TextMate does not know how to execute a Perl script and display the results to you. Have you tried running it from the shell?
您是否安装了
/usr/local/bin/perl
?which perl
在终端返回什么?如果您的 hashbang 行不正确,那么当您在 TextMate 中运行脚本时,您只会得到一个空的输出窗口。 Textmate 不会给出任何错误,表明它无法找到您在 #! 之后指定的可执行解释器。 :(
将第一行替换为 #!/usr/bin/env perl ,它将运行您登录的默认 Perl(在 $PATH 环境变量中找到)。/
I3az/
Do you have
/usr/local/bin/perl
installed? What doeswhich perl
return at the terminal?If your hashbang line is incorrect then when you come to run the script in TextMate you will just get an empty output window. Textmate does not give any error that it couldn't find the executable interpreter you prescribed after #! :(
Replace the first line with
#!/usr/bin/env perl
and it will run you login's default Perl (found in $PATH environment variable)./I3az/