开发者

Why can't I run a Perl program from TextMate?

开发者 https://www.devze.com 2022-12-22 22:00 出处:网络
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 an

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 sc开发者_JAVA百科ript 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";


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";


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?


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/

0

精彩评论

暂无评论...
验证码 换一张
取 消