In fact, LWP::Simple will indeed do the same trick.
#!/usr/bin/perl -w use strict; use LWP::Simple; getprint 'http://xxx.xx.xx.xx/dir/index.html';
Actually you can just do it in a oneliner. $ perl -MLWP::Simple -e'getprint shift' 'http://xxx.xx.xx.xx/dir/index.html'

If you need to store the page content in a variable, it's as easy as using get() instead. See the POD for futher info.

Given this, I really think you shouldn't reinvent the wheel using Expect - what you messed up, as you see, was a related to the HTTP protocol, not your Perl code. LWP has been written to handle all the details of the protocol for you - so you're better off using that instead of writing fragile hacks. I'm not flaming, this is honest advice. :) See my signature too..

Makeshifts last the longest.


In reply to Re: Using Expect mod to telnet to port 80 (HTTP) by Aristotle
in thread Using Expect mod to telnet to port 80 (HTTP) by ATB

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.