Greetings Monks, I need to modify a program to output to a file instead of STDOUT. I have consulted
http://search.cpan.org/~gaas/libwww-perl-6.02/lib/LWP/UserAgent.pm
but still don't know what to do. The following script is a model provided by http://www.uniprot.org/faq/28 to convert one form of a protein ID to another, It outputs to the screen and I need it to go to a file:
use strict; use warnings; use LWP::UserAgent; my $base = 'http://www.uniprot.org'; my $tool = 'mapping'; my $params = { from => 'ACC', to => 'P_REFSEQ_AC', format => 'tab', query => 'P13368 P20806 Q9UM73 P97793 Q17192' }; my $agent = LWP::UserAgent->new; push @{$agent->requests_redirectable}, 'POST'; my $response = $agent->post("$base/$tool/", $params); while (my $wait = $response->header('Retry-After')) { print STDERR "Waiting ($wait)...\n"; sleep $wait; $response = $agent->get($response->base); } $response->is_success ? print $response->content : die 'Failed, got ' . $response->status_line . ' for ' . $response->request->uri . "\n";
Thanks,next time I'll do the tutorial on OOP. Chet

In reply to LWP::UserAgent -output to file? by cseligman

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.