Hello all,<br><br>I've gotten back to hacking with perl again.&nbsp; I'm confused by the output of a little program I'm writing.&nbsp; It builds a query in the form of a url to PubMed and parses the returning xml for the 'count' field.&nbsp; Fine so far.&nbsp; After that, I'm trying to print out results in a particular format; namely, query term(gene), tab, count, newline.
<br><br>But the output is coming out query term(gene), newline,tab, count, newline.&nbsp; O Great Mongers! Where is the extra newline coming from? I've tried to chop and chomp both variables ($gene and $NumAbstracts) but to no avail.
<br><br>Any help would be appreciated.<br>Thanks,<br>Ganesh<br><br>&lt;/code&gt;<br><br>#!/usr/bin/perl<br>use strict;<br>use warnings;<br>use LWP;<br><br><br>if ($#ARGV != 0) {<br>&nbsp;&nbsp;&nbsp; print &quot;usage: getCitNum geneFileName \n&quot;;
<br>&nbsp;&nbsp;&nbsp; exit;<br>}<br><br>my $geneFile = $ARGV[0];<br>my @gene=();<br>my $size;<br># Creates the URL to search Pubmed<br>my $baseurl=&quot;<a href="http://www.ncbi.nlm.nih.gov/entrez/eutils/esearch.fcgi?">http://www.ncbi.nlm.nih.gov/entrez/eutils/esearch.fcgi?
</a>&quot;;<br>my $request;<br>my $response;<br>my $query;<br><br>open( FILE, &quot;&lt; $geneFile&quot; ) or die &quot;Can't open $geneFile : $!&quot;;<br><br>&nbsp;&nbsp;&nbsp; while( &lt;FILE&gt; ) {<br>&nbsp;&nbsp;&nbsp; next if /^(\s)*$/;&nbsp; # skip blank lines
<br>&nbsp;&nbsp;&nbsp; ##chomp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; # remove trailing newline characters<br>&nbsp;&nbsp;&nbsp; ##print &quot;pushed &quot;.$_.&quot; into array&quot;;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; push @gene, $_;&nbsp;&nbsp;&nbsp; # push the data line onto the array<br>&nbsp;&nbsp;&nbsp; }<br><br>&nbsp;&nbsp;&nbsp; close FILE;
<br>&nbsp;&nbsp;&nbsp; <br><br>$size = scalar @gene;<br>print &quot;Number of genes: $size.\n&quot;;<br><br><br>## iterate through the gene array<br><br>foreach my $gene (@gene){<br><br>##print &quot;going through the array!&quot;,&quot;\t&quot;, $gene;
<br><br>##$query=join(&quot; &quot;, $gene);<br>my $url=$baseurl . &quot;db=Pubmed&amp;retmax=1&amp;usehistory=y&amp;term=&quot; . $gene;<br>$request=LWP::UserAgent-&gt;new();<br>$response=$request-&gt;get($url);<br>my $results= $response-&gt;content;
<br>die unless $response-&gt;is_success;<br>$results=~/&lt;Count&gt;(\d+)&lt;\/Count&gt;/;<br>## $1 is the symbol for the matched content<br>&nbsp;&nbsp; my $NumAbstracts=$1;<br><br>print $gene,&quot;\t&quot;,$NumAbstracts.&quot;\n&quot;;
<br><br>}#end foreach gene array<br><br>&lt;/code&gt;<br><br>&lt;/output&gt;<br><br>$ perl o3.pl test_f<br>Number of genes: 8.<br>Actn1<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 5<br>Actn4<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 68<br>Adfp<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 74<br>Aldh2<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 656<br>
&quot;Siahbp1, simi&quot;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 0<br>1810057F21Rik<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 0<br>2310035N23Rik<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 0<br>2310040G17Rik&nbsp;&nbsp; 0<br><br>&lt;/output&gt;<br>