Hi, I'm currently writing a perl-wrapper for Debians aptitude. The wrapper should just color some parts of the output. If I want to install a package, aptitude usually asks 'Do you want to continue? [Y/n/?]' without appending a \n after the question. The problem is, that my wrapper does not display this question until I enter something at the keyboard. This looks as follows:
... Need to get 667kB of archives. After unpacking 3965kB will be used. y Do you want to continue? [Y/n/?] Writing extended state information... ...
The actual question is printed after my input. Currently, the executed code in the wrapper is very simple:
print $_ while (<STDIN>);
To get the whole thing running, I pipe the output of aptitude into the wrapper: sudo aptitude install xyz | ./wrap.pl After playing around for a while now, I know that's a problem of buffering but I'm not sure how to bypass it.

Thanks


In reply to I/O buffering problem by pwr

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.