Lookfor and I/O ProcessingSome communications programs have a different need - to collect (or discard) input until a specific pattern is detected. For lines, the pattern is a line-termination. But there are also requirements to search for other strings in the input such as "username:" and "password:". The lookfor method provides a consistant mechanism for solving this problem. It searches input character-by-character looking for a match to any of the elements of an array set using the are_match method. It returns the entire input up to the match pattern if a match is found. If no match is found, it returns "" unless an input error or abort is detected (which returns undef).
CountZero
A program should be light and agile, its subroutines connected like a string of pearls. The spirit and intent of the program should be retained throughout. There should be neither too little or too much, neither needless loops nor useless variables, neither lack of structure nor overwhelming rigidity." - The Tao of Programming, 4.1 - Geoffrey James
My blog: Imperial DeltronicsIn reply to Re: parse data from serial port
by CountZero
in thread parse data from serial port
by pashanoid
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |