If you are able to poll your input channel to see whether there's any data waiting before attempting to read it (as you can with serial input), you might consider doing so in a
repeat callback. I've done this using a string as a queue, appending new data to the end, and processing (and deleting) syntactic chunks as they appear. (Regexes are great for recognizing and extracting such chunks.)
When such polling is not possible, you can use fileevent, but I might think twice about trying to handle the data every time it triggers a callback. Better just to enqueue it and get out. Then use a repeat callback to recognize, dequeue, and process the data at a controllable rate. That way you won't be trying to process every individual byte as it comes in at the risk of slowing GUI response to a crawl.
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: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.