in reply to Do While, While

The answer is 'use a thread'. Now the question becomes, what are you doing with the input from the stream?


Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
"Science is about questioning the status quo. Questioning authority".
In the absence of evidence, opinion is indistinguishable from prejudice.
"Too many [] have been sedated by an oppressive environment of political correctness and risk aversion."

Replies are listed 'Best First'.
Re^2: Do While, While
by iea (Beadle) on Apr 07, 2008 at 18:35 UTC
    I keep on reading the stream. I´m saving information of coming commands.
    # Keep reading lines from the server. while (my $input = <$server>) { #save incoming information to database ... do this and that # Check errormessages and .... }
    But I would still like to use the frontend

      This ain't gonna do what you need to do, but given the sparsity of information supplied...

      use threads; ... async{ # Keep reading lines from the server. while (my $input = <$server>) { #save incoming information to database ... do this and that # Check errormessages and .... } };

      Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
      "Science is about questioning the status quo. Questioning authority".
      In the absence of evidence, opinion is indistinguishable from prejudice.
Re: Do While, While
by iea (Beadle) on Apr 07, 2008 at 19:12 UTC
    thanks i´ll try

      Try this. It's a starting point.

      #! perl -slw use strict; use threads; use Win32::GUI; my $mw = Win32::GUI::Window->new( -name => 'Main', -width => 500, -height => 500, ); my $lb = $mw->AddListbox( -name => 'LB' ); $lb->Add( 'Line ' . $_ ) for 1 .. 10; $mw->Show(); my $thread = async{ my $lb = shift; $SIG{'KILL'} = sub { return 0; }; my $n = 11; while( sleep 1 ) { $lb->Add( 'Line ' . $n++ ); } } $lb; $thread->detach; Win32::GUI::Dialog(); exit(0); sub Main_Terminate { $thread->kill( 'KILL' ); return -1; } sub Main_Resize { $lb->Width( $mw->Width ); $lb->Height( $mw->Height ); } sub LB_Click { print 'click'; } sub LB_MouseRightDown { print 'Rclick'; }

      Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
      "Science is about questioning the status quo. Questioning authority".
      In the absence of evidence, opinion is indistinguishable from prejudice.
        Great thanks ... thats what i needed. =) Thank you