Hello, Brian,

BM> while ($$data =~ s/^(.*?\n)//) {
        $self->>process_command($1);
BM> }

BM> That little regex in there is killing my performance.  If one uses select,
BM> one must expect to read partial or multiple lines.  That means that one must
BM> search for line terminators, and that is precisely what I am trying to get
BM> around without having to resort to threads or forking.

BM> Of course I know regexes are evil, index() is much better in performance,
BM> but it still doesn't solve what I am truly after, and that is a select()
BM> that returns when a complete line of data is available, not just a few
BM> characters.

would it be possible for you to switch to a stream protocol? In that
case, you could read blocks of data, knowing their length before,
using fast sysread() or read() calls, without need to investigate the
data by a regular expression.

Such protocols are available in CPAN. POE, for example, has them (I
only read about them, but I think the block IO wheels would do this).
Or have a look at IPC::LDT, which implements such a protocol directly
and handles data transparently, so you could send everything including
your terminator and expect to receive it as one block on the other
side (the block length is determined dynamically). It can be used with
Event.

                Jochen

                

Reply via email to