my $doStdout = sub {
## $Qout is a [Thread::Queue] object onto which anything that is printed to stdout is enqued by the "black magic".
## It is created by the statement my $Qout = new Thread::Queue;.
## If you look up the documentation for that module you'll see that the pending() method returns
## the count of 'things' in the the queue. Using that information, the next line of code reads:
## If there is anything in the queue -- ie. if the parent program has printed anything to stdout
if( $Qout->pending ) { # no clue
my $output = $Qout->dequeue; # read STDOUT of .pl into var ## YES.
$lb->insert( 'end', $output ) ; # print STDOUT of .pl in listbox ## YES.
## We've inserted the next item into the listbox,
## but this addition may have gone 'off the bottom' of the visible part of the listbox
## so ask the listbox to redraw itself to ensure that we can 'see' the 'end'
## ie. the last item in the listbox. Ie. the one we just added.
$lb->see( 'end' ); # What's this?
if( $output eq 'whatever' ) {
# actual Tk code
}
}
};