I've looked at POE. Yes, it's a big hammer, but I still don't know the
underlying enabling technology. Too much source to go through, and I've
been looking at alternatives for over a week now.
For instance, the IO::Multiplex package has exactly what I need; and indeed
I've duplicated what is in the package not knowing that it already exists,
and the crux of my problem with select() is the following snippet from the
CPAN documentation:
Rob Brown > IO-Multiplex-1.08 > IO::Multiplex
while ($$data =~ s/^(.*?\n)//) {
$self->process_command($1);
}
That little regex in there is killing my performance. If one uses select,
one must expect to read partial or multiple lines. That means that one must
search for line terminators, and that is precisely what I am trying to get
around without having to resort to threads or forking.
Of course I know regexes are evil, index() is much better in performance,
but it still doesn't solve what I am truly after, and that is a select()
that returns when a complete line of data is available, not just a few
characters.
> -----Original Message-----
> From: Rocco Caputo [mailto:[EMAIL PROTECTED]
> Sent: Monday, March 01, 2004 4:46 PM
> To: Brian Michalk
> Subject: Re: New Guy Questions
>
>
> On Mon, Mar 01, 2004 at 08:58:43AM -0600, Brian Michalk wrote:
> > I have a base class that abstracts out a lot of file handle
> handling. It
> > manages, FIFOs, sockets, STDIO, and reading of device drivers.
> >
> > The root of the problem is that I need to use something like select() to
> > tell me when there is data without blocking the entire process.
> Some data
> > comes in character at a time whereas others come in line at a time.
> >
> > The problem is that select() doesn't play well with buffers, so
> I have to
> > manage my own line discipline which uses \n as the data separator. The
> > performance is terrible because I have to write for the worst
> case of the
> > slow writers.
> >
> > I tried threads, and was underwhelmed. Too much memory, and
> initial results
> > were not all that much better on the CPU usage.
> >
> > How does Event.pm compare with CPU utilization? Can I have it watch a
> > filehandle that triggers when a line separator is received? I
> hope so, but
> > the documentation sounds strangely familiar to a select()
> driving the heart
> > of the system.
>
> POE does the higher-level things you're looking for, but it might be
> too high level for what you want to do. Examples are at
> http://poe.perl.org/?POE_Cookbook
>
> --
> Rocco Caputo - [EMAIL PROTECTED] - http://poe.perl.org/
>