Command line version. Adapt, amend, etc as necessary. What NetWallah said. Use CGI if you’re keeping it in the CGI realm (or another modern framework). Required reading: XML::LibXML, XML::LibXML::Node, URI, and as a pre-emptive measure if the following are daunting: Yes, even you can use CPAN, local::lib, cpanm. Getopt::Long if you want deep(er) argument handling.

#!/usr/bin/env perl # Script/file named pm-1109805 use strictures; use XML::LibXML; use URI; my $term = shift || die "Give a term to search the nuccore DB!\n"; my %args = ( db => "nuccore", retmax => 1, usehistory => "y", term => $term ); my $uri = URI->new("http://www.ncbi.nlm.nih.gov/entrez/eutils/esearch. +fcgi"); $uri->query_form(%args); # If you don't expect errors and don't need cookies etc, use XML::LibX +ML, # if you do, use LWP::UserAgent or WWW::Mechanize or something. my $dom = XML::LibXML->load_xml( location => $uri->as_string ); # Expecting exactly ( one ), findnodes returns a list. my ( $result ) = $dom->findnodes("/eSearchResult"); my $error = $result->findvalue("/ERROR"); die "Error:", "$error", $/ if $error; my $count = $result->findvalue("Count"); my $showing = $result->findvalue("RetMax"); printf "Found %d result%s. Showing %d (RetMax).\n", $count, $count == 1 ? "" : "s", $showing; for my $id ( $result->findnodes("IdList/Id") ) { print "Id: ", $id->textContent, $/; } # print $dom->serialize(1); # To see the raw XML.
moo@cow[54]~>pm-1109805 NM_000040 Found 1 result. Showing 1 (RetMax). Id: 4557322 moo@cow[55]~>pm-1109805 asdf Found 15 results. Showing 1 (RetMax). Id: 57648377

In reply to Re: CGI and Perl script one file, passing arguments by Your Mother
in thread CGI and Perl script one file, passing arguments by newtoperlprog

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.