Question: Unable to run a perl sample file on ubuntu
0
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 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

ncbi perl • 161 views
ADD COMMENTlink modified 10 weeks ago by genomax91k • written 10 weeks ago by nadarajan_v0
0
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.

Help
Access

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