Beefy Boxes and Bandwidth Generously Provided by pair Networks
Your skill will accomplish
what the force of many cannot

Re^5: Perl/Tk code structure

by BrowserUk (Pope)
on Jan 17, 2012 at 23:23 UTC ( #948439=note: print w/replies, xml ) Need Help??

Help for this page

Select Code to Download

  1. or download this
        my $doStdout = sub {
             ## $Qout is a [Thread::Queue] object onto which anything that
    + is printed to stdout is enqued by the "black magic".
  2. or download this
        $mw->repeat( 500, $doStdout ); # execute $doStdout once every 500 
    +millisec...? but why mw->
         Tk::MainLoop(); #OK
  3. or download this
    use Thread::Queue;
     tie *STDOUT, 'MyGuiStdout', $Qout;
     # everything up to this point is pure black magic
  4. or download this
    sub PRINT  { $_[0]->enqueue( join ' ', @_[ 1 .. $#_ ] ); }
  5. or download this
    package MyGuiStdin;
    our @ISA = qw[ Thread::Queue ];
    sub TIEHANDLE { bless $_[1], $_[0]; }
    sub READLINE { $_[0]->dequeue(); }

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://948439]
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others rifling through the Monastery: (3)
As of 2016-10-23 06:24 GMT
Find Nodes?
    Voting Booth?
    How many different varieties (color, size, etc) of socks do you have in your sock drawer?

    Results (300 votes). Check out past polls.