Re: perl foreach with Gtk2::Helper/Glib::IO




On Nov 11, 2008, at 8:26 PM, MICHAEL MCGINN wrote:

It works great for the last member in the array but will not process the other members.

I'll wager you're blocking and it winds up slupring in all output from that process.


            if ($condition >= 'in') {
                $line = <$fh>;

There's one problem. This input operator will block until it gets a newline. You need to use sysread() to read whatever's available. You *will* get partial lines. That's fine for something that loads the text into a TextView. If you really need full lines for matching, then you'll want to do framing yourself -- create an object to encapsulate each watch handler, and keep a state variable with the last partial line, to which you append on the next read.


                Gtk2->main_iteration while(Gtk2->events_pending);

Don't do that in an i/o watch handler --- just return control to the main loop.




--
Santa ate all the cookies!
  -- Zella's first, indignant words on Christmas morning, '07.




[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]