tags:

views:

265

answers:

3

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";
+3  A: 

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";
Ether
Oh, the simple test failed. I run ruby scripts all the time on this thing, this is my first attempt with perl on this program
JZ
What would you suggest in terms of Textmate editor configuration?
JZ
The next thing I'd suggest after that would be to put the `use lib "/Users/fogonthedowns/myperllib";` line before the `print` or `warn`. I don't know what's at that location or how well the library is written.
David Thornley
@JZ: I have no idea; my home machine is a mac laptop, but I use vim and the command line for everything. You'll probably find some information on TextMate configuration at superuser.com.
Ether
+2  A: 

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?

Svante
in terminal I used perl ncbi.pl to execute the program
JZ
With what result?
Svante
+2  A: 

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/

draegtun