Question: Unable to run a perl sample file on ubuntu
gravatar for nadarajan_v
10 weeks ago by
nadarajan_v0 wrote:

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

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 = '';
$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:

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


ncbi perl • 161 views
ADD COMMENTlink modified 10 weeks ago by genomax91k • written 10 weeks ago by nadarajan_v0
gravatar for nadarajan_v
10 weeks ago by
nadarajan_v0 wrote:

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

ADD COMMENTlink written 10 weeks ago by nadarajan_v0
Please log in to add an answer.


Use of this site constitutes acceptance of our User Agreement and Privacy Policy.
Powered by Biostar version 2.3.0
Traffic: 1735 users visited in the last hour