Unable to run a perl sample file on ubuntu
1
0
Entering edit mode
4.4 years ago

I am trying to run a sample Perl code provided at the NCBI Entrez site. The following is the code, I just added the first line to the code which copied from the site and saved it as asthma.pl.

#!/usr/bin/perl
use LWP::Simple;
# Download PubMed records that are indexed in MeSH for both asthma and
# leukotrienes and were also published in 2009.
$db = 'pubmed';
$query = 'asthma[mesh]+AND+leukotrienes[mesh]+AND+2009[pdat]';
#assemble the esearch URL
$base = 'https://eutils.ncbi.nlm.nih.gov/entrez/eutils/';
$url = $base . "esearch.fcgi?db=$db&term=$query&usehistory=y";
#post the esearch URL
$output = get($url);
#parse WebEnv and QueryKey
$web = $1 if ($output =~ /<WebEnv>(\S+)<\/WebEnv>/);
$key = $1 if ($output =~ /<QueryKey>(\d+)<\/QueryKey>/);
### include this code for ESearch-ESummary
#assemble the esummary URL
$url = $base . "esummary.fcgi?db=$db&query_key=$key&WebEnv=$web";
#post the esummary URL
$docsums = get($url);
print "$docsums";
### include this code for ESearch-EFetch
#assemble the efetch URL
$url = $base . "efetch.fcgi?db=$db&query_key=$key&WebEnv=$web";
$url .= "&rettype=abstract&retmode=text";
#post the efetch URL
$data = get($url);
print "$data";

When I ran it on Ubuntu 18.03, I am getting the following error:

  $ ./asthma.pl
    ./asthma.pl: line 1: use: command not found
    ./asthma.pl: line 4: =: command not found
    ./asthma.pl: line 5: =: command not found
    ./asthma.pl: line 7: =: command not found
    ./asthma.pl: line 8: =: command not found
    ./asthma.pl: line 10: syntax error near unexpected token `('
    ./asthma.pl: line 10: `$output = get($url);'

Thanks

Perl ncbi • 938 views
ADD COMMENT
0
Entering edit mode
4.4 years ago

There was a blank line at the top, which was invisible on sublime text program. Once I removed it, it worked fine.

ADD COMMENT

Login before adding your answer.

Traffic: 2356 users visited in the last hour
Help About
FAQ
Access RSS
API
Stats

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.

Powered by the version 2.3.6