BrowserUk, you bloody champ you !!
Guess what, I found out a way aswell ! Using IO::Pipe.
I figured out the following way to achieve my goal but you beat me to it.. L: hehe. And you know what, It's the repeat Tk method aswell o_(.
PLUS, I am using fork again. When I said I wasn't going to. But your way is very nice.
use IO::Pipe;
use Tk;
$pipe = new IO::Pipe;
create_tk_window();
if($pid = fork()) { # Parent
$pipe->reader();
$mw->MainLoop;
}elsif(defined $pid) { # Child
$pipe->writer();
while(1) {
write_to_pipe();
}
}
sub write_to_pipe {
$pipe->write("Who's a jebroni - Not me Not me");
}
sub display_handle_data {
my $pipe_data;
$pipe->sysread($pipe_data,100024);
$server_list_listbox->insert('end',"GOT $pipe_data");
$server_list_listbox->see('end');
}
sub create_tk_window {
$mw=MainWindow->new
(
-background=>'#dedede',
-foreground=>'yellow',
-title=>"FingerLick - Only eye nows the gows wehn the wind blo
+ws"
);
$mw->geometry("802x618");
$mw->minsize(802,618);
$mw->maxsize(802,618);
$mw->repeat(1.001,sub { display_handle_data() });
$sent_recvd_listbox=$mw->Listbox
(
-height=>1,
-width=>60,
-background=>'black',
-foreground=>'yellow'
)->pack(-side=>'bottom',-anchor=>'s',-pady=>2);
$server_list_listbox=$mw->Scrolled
(
"Listbox",
-height=>20,
-width=>60,
-background=>'white',
-foreground=>'black',
-scrollbars=>'se',
)->pack();
}
The Threads::Queue method that you have suggested may be the winner I think.
We shall see after some tests...etc..
Thank you very much BrowserUk.
Now things are moving forward a lil more...
I wanted to finish this thing by this weekend, looks like I may now.
Thanks alot mate : _)
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: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.