为什么我无法从 TextMate 运行 Perl 程序?

发布于 2024-08-24 11:46:51 字数 648 浏览 5 评论 0原文

我正在阅读一本生物信息学文本,这代表了我的第一个 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 技术交流群。

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

发布评论

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

评论(3

歌入人心 2024-08-31 11:46:51

您在 TextMate 中成功运行过其他脚本吗?我怀疑您有编辑器配置问题(或者 URL 不可命中且脚本生成错误)。

尝试运行一个更简单的脚本,看看会发生什么,例如:

#!/usr/local/bin/perl -w
print "hello world\n";

接下来,看看是否可以看到错误输出:

#!/usr/local/bin/perl -w
warn "oh noes";

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:

#!/usr/local/bin/perl -w
print "hello world\n";

Next, see if you can see error output:

#!/usr/local/bin/perl -w
warn "oh noes";
ゝ杯具 2024-08-31 11:46:51

最有可能的是,您的执行环境没有以正确的方式设置,即 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?

勿忘初心 2024-08-31 11:46:51

您是否安装了 /usr/local/bin/perlwhich perl 在终端返回什么?

如果您的 hashbang 行不正确,那么当您在 TextMate 中运行脚本时,您只会得到一个空的输出窗口。 Textmate 不会给出任何错误,表明它无法找到您在 #! 之后指定的可执行解释器。 :(

将第一行替换为 #!/usr/bin/env perl ,它将运行您登录的默认 Perl(在 $PATH 环境变量中找到)。/

I3az/

Do you have /usr/local/bin/perl installed? What does which 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/

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