Thanks for all of the suggestions, folks. Here is some additional information, as requested:
1) I have done a "View Source" from within Firefox to verify that there are line breaks within the source HTML, although I don't know if those are "\r\n" or just "\n". However, my cygwin environment is set up to use UNIX line endings, and it still experiences the problem.
2) Some of the sites I have tried include www.cnn.com and www.cdc.gov. In general, some of the line breaks within <script> elements seem to get preserved, but outside of those most of the HTML appears on a single line.
3) I have tried changing the agent to "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1)", but I got the same results. I haven't tried using any other agent settings other than the default yet.
4) I have tried using the content returned by LWP::UserAgent with HTML::TreeParser, but it didn't seem to help, although I may need to experiment more with that.
Some additional info - I tried running my test script on another machine running Windows XP Home, and it worked fine there (i.e. whitespace was preserved), so the issue appears to be isolated to my work laptop running XP Pro. I've also tried using the Socket module to download the HTML on that machine, and I experience the same issue of whitespace being removed. Based on that, I suspect this isn't an issue specifically with LWP, but I'm not quite sure what to check next.
Thanks again for all of the help.
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: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.