Beefy Boxes and Bandwidth Generously Provided by pair Networks
P is for Practical

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 wandering the Monastery: (6)
As of 2015-11-28 06:16 GMT
Find Nodes?
    Voting Booth?

    What would be the most significant thing to happen if a rope (or wire) tied the Earth and the Moon together?

    Results (738 votes), past polls