Craig also asked at http://perlmonks.org/?node_id=775181 so I replied
there. There's no point in having this conversation in two places.
The code was small enough to include on the list.
Please only post good code to the Cookbook.
Corollary: please report (or fix) broken code in the Cookbook.
--
Rocco Caputo - rcap...@pobox.com
On Jun 26, 2009, at 12:19, Craig Votava wrote:
Folks-
I have a simple problem that I want to solve with POE. As I'm
looking at all the various options, I'm getting overwhelmed and need
some help picking out the "best".
I have an ascii logfile (non-growing) that I want to represent in a
GUI (using Tk). My code so far, creates a POE session, and builds
the GUI output window (which is ready to start getting data to add
into it).
Now I need to read in the data, parse it into an internal data
structure, then feed that to the GUI for display.
What is the best way to do this? Here are what I think are my 2 best
thoughts so far:
1.) Same session: use Tk's fileevent to get any data that is
available, then parse it, then display it (POE handles the
sequencing so the GUI still functions while the reading-in and
parsing is happening, right?).
2.) Separate sessions: Create a filter that parses the data and use
something like POE::Wheel::FollowTail starting it at the beginning
of the file. Use events between the two sessions to alert the GUI
there's a new internal data structure ready for slapping up on the
GUI.
Can the POE experts help me understand why I would want one over the
other?
Are there any better options?
Would it make sense to post this result into the cookbook (I
couldn't find an example of this anywhere)? Any pointers are
appreciated.
Thanks
-Craig