I have a small script that connects to a remote network element on a given port, issues a command, saves the results into an array using getlines, and then prints the data back to me. My problem (I think) is that the data is output with some very small delays that getlines seems to be interpreting as EOF. If I try to store the output in a single array, I get 17 lines. If I add a second getlines with a second array, I get an additional 21 lines. The third getlines grabs the last line, for a total of 39 lines. The problem is, the number of lines varies, and I can't keep just adding getlines and hoping that I get all the data. Why is getlines doing this? I've tried adding a Timeout to getlines, and to my initial open, but this does nothing. The pertinent lines are below, along with some of my debugging. Thanks for any suggestiions.
$connect = new Net::Telnet (Telnetmode => 0); $connect->open(Host => $hostname, Port => $port); $connect->print("$rtrv"); (@prematch,$match) = $connect->waitfor('/COMPLD/'); @rlines = $connect->getlines; @alines = $connect->getlines; @blines = $connect->getlines; print @rlines; print "\nShoud have all printed there...\n\n"; print @alines; print "\nAnd that was the second array\n\n"; print @blines; print "\n"; print "\nThat is the last of it\n\n";

In reply to How do I force getlines to get ALL the data? by Galen

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.