All, First off, This is my first posting here and I'd consider myself an intermediate Perl user at best, so don't be surprised by my ignorance on this. Now on to the question:

I have a script where I am posting a GET request using HTTP::Request and the LWP::UserAgent module. I get my response with:

$response = $ua->request($request);

I am able to print the content to stdout with:

print $response->content;

HOWEVER, I cannot print this to a file. When I try to print the contents to file I get an empty file. What I am really trying to do is access the content data from a calling C program with popen, but that does not work since nothing is going to stdout (at least from what I can tell).

I figured that if I am able to print the content to stdout as above then it is essentially, "What you see is what you get". I am inclined to believe I am missing something. Namely, some kind of encoding that Perl makes transparent to the user when they call a simple print command from within the script?

PLEASE help as I have been pulling my hair out half the day over this stupid thing and I know I am missing something relatively trivial. THANK YOU.


In reply to Cannot access HTTP::Response content properly by URAvgDeveloper101

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.