Hello Monks!

I am using PUBCHEM's PUG REST service to download properties of a specific chemical compound. I want to give STDIN input of the chemical compound in the form of a SMILES string (it's a format to represent a chemical compound, like a molecular formula). The PUG REST URL format looks like this:

http://pubchem.ncbi.nlm.nih.gov/rest/pug/compound/smiles/CCC/property/MolecularFormula,MolecularWeight,TPSA/CSV/

http://pubchem.ncbi.nlm.nih.gov/rest/pug/compound/smiles/<smiles string>/property/<properties of interest>/<output file format>/

Now, how do I STDIN my smiles string in the above format of URL? I've tried some little tricks like this:

#!/usr/bin/perl use LWP::Simple; my $smiles = <STDIN>; my $url = 'http://pubchem.ncbi.nlm.nih.gov/rest/pug/compound/smiles/'; + my $finalurl = get "$url$smiles/property/MolecularFormula,MolecularWei +ght,TPSA/CSV/"; print $finalurl;
and warning was: Use of uninitialized value $finalurl in print at test_lwp.pl line 12. Thanks in advance :)


In reply to How to use STDIN in between a URL? by piscean

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.