You could easily make use of the Net::Telnet->recv() subroutine here, it allows you to specify how many bytes you'd like to receive at a time like so:

$tel->recv($buffer, 512);

Would retrieve 512 bytes from the $tel object into the $buffer scalar.

If you were simply retrieving the data for storage, it'd be pretty simple to write something like this:

open(OUTPUT, '>output.file'); while($tel->recv($buffer, 512)) { print OUTPUT $buffer; } close OUTPUT;
However, you noted that you'll be further editing the data before you're done with it, and also I get the sense that memory seems to be a primary concern in the issue.

One solution to this would be to use IO::File to create a temporary file to store the data in until you're done editing it:

my $output = IO::File->new_tmpfile(); while($tel->recv($buffer, 512)) { $output->print($buffer); }
Now, all of the output from your telnet session has been stored in the $output temporary file which you can use for further parsing and editing.


In reply to Re: Non buffered telnet? by tekkie
in thread Non buffered telnet? by efreed

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.