cmv has asked for the wisdom of the Perl Monks concerning the following question:
Wise Monks-
In my environment there exists an application that creates a raw ascii data file on a given host in real time. I wanted to take this raw data and put it up in a GUI analysis window, so I wrote a POE-based Perl-Tk script, which uses POE::Wheel::FollowTail (Thanks Rocco, et. al.) as the data feed and uses Perl-Tk as the GUI. This works very well.
Now, the application has a "-binary" option, which will create a raw binary file on a given host in real time. I want my GUI analysis program to be able to work with this data as well. What should I do?
Being lazy, I was hoping I could just define a different filter for POE::Wheel::FollowTail, that instead of being line oriented, would be record oriented (each record begins with 0xfefefefe).
I currently have a binary parser that can parse the data. Assuming the binary data is slurped up into the scalar "$data", the following code works great:
Update: The regular expression shown here is very wrong (works in some basic cases, blows chunks on most fringe cases) - Please ignore it and see my next comment on this node for a much better example.
Being very new to POE and filters, is there something already existing that I could use? I've toyed with modifying one of the following:while($data) { # Find next beginning-of-record flag & extract record... $data =~ s/^[^\xfe]*(\xfe\xfe\xfe\xfe[^\xfe]+)// || die "No luck"; my $event=$1; # Send record to parser... $parser->parse( $event ); # Print restult... print "events DUMP:\n", Dumper($parser->{events}), "\n"; } }
POE::Filter::RecordBlock
POE::Filter::Regexp
POE::Filter::Block
Do any of these make sense for what I want to do? Should I punt on using FollowTail and try something else?
Any advice is appreciated!
-Craig
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
POE::Wheel::FollowTail to read binary records - solved?
by cmv (Chaplain) on Mar 20, 2009 at 15:15 UTC | |
|
Re: POE::Wheel::FollowTail to read binary records - solved!
by cmv (Chaplain) on Mar 20, 2009 at 16:26 UTC |