This was also posted to the POE mailing list...

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.

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"; } }
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:

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


In reply to POE::Wheel::FollowTail to read binary records!?! by cmv

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • 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:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.