Capture the STDOUT, sure. But STDOUT of what?

If it is output from your own script, do yourself a favor, and simply change all the relevant print statements with calls to a routine that appends to the widget.

If not, are you trying to catch the output of some command that completes quickly? (like, say, man or ls)

In that case, use $var=`command` to capture the stdout of the command into your variable.

If it is the output of a program that will take a while to execute, and produce output at various points in time, then you should open that program with a pipe, like so:

open(COM,"command |") || die "Could not execute command\n";
. In the last case you will have to arrange something that will check for new output on a regular basis. File::Tail may be of some use with that.

In reply to Re: Perl:TK - standard output to text widget by matija
in thread Perl:TK - standard output to text widget by crabbdean

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.