[From nobody Mon Mar 31 00:27:29 2008 Received: from la.mx.develooper.com (HELO x1.develooper.com) (63.251.223.176) by la.mx.develooper.com (qpsmtpd/0.28) with SMTP; Sat, 29 Mar 2008 08:34:19 -0700 Received: (qmail 12056 invoked from network); 29 Mar 2008 15:34:16 -0000 Received: (qmail 12102 invoked by uid 225); 29 Mar 2008 15:34:23 -0000 Received: (qmail 12096 invoked by alias); 29 Mar 2008 15:34:22 -0000 Received: from x16.dev (10.0.100.26) by x1.dev with QMQP; 29 Mar 2008 15:34:16 -0000 Received: by 10.143.6.1 with SMTP id j1mr2710618wfi.45.1206804848553; Sat, 29 Mar 2008 08:34:08 -0700 (PDT) Received: by 10.142.106.16 with HTTP; Sat, 29 Mar 2008 08:34:08 -0700 (PDT) Received: from wx-out-0506.google.com (HELO wx-out-0506.google.com) (66.249.82.236) by 16.mx.develooper.com (qpsmtpd/0.43rc1) with ESMTP; Sat, 29 Mar 2008 08:34:12 -0700 Received: by wx-out-0506.google.com with SMTP id t5so689283wxc.16 for <moscow-pm@pm.org>; Sat, 29 Mar 2008 08:34:09 -0700 (PDT) Received: from x1a.develooper.com (HELO x1.develooper.com) (216.52.237.111) by x6.develooper.com with SMTP; 29 Mar 2008 15:34:23 -0000 Received: (qmail 76458 invoked from network); 29 Mar 2008 15:34:33 -0000 Received: (qmail 76462 invoked by uid 22626); 29 Mar 2008 15:34:33 -0000 Received: from unknown (HELO x6.develooper.com) (63.251.223.186) by mx1.masterhost.ru with SMTP; 29 Mar 2008 15:34:31 -0000 Received: (qmail 11932 invoked from network); 29 Mar 2008 15:34:23 -0000 Received: from x6.develooper.com (localhost.localdomain [127.0.0.1]) by x6.develooper.com (Postfix) with ESMTP id E87C423738 for <subscribe@tochkak.ru>; Sat, 29 Mar 2008 08:34:29 -0700 (PDT) Return-Path: <moscow-pm-bounces+subscribe=tochkak.ru@pm.org> Reply-To: "Moscow.pm group" <moscow-pm@pm.org> From: "Ruslan Zakirov" <ruz@bestpractical.com> Sender: <moscow-pm-bounces+subscribe=tochkak.ru@pm.org> To: "Moscow.pm group" <moscow-pm@pm.org> References: <47DE5F79.7080309@serezhkin.com> <589c94400803281733h273cefc1y9342d96f567af7be@mail.gmail.com> <47EE5579.3080000@serezhkin.com> <589c94400803290752i1ab2696fmf97682dcb64324a9@mail.gmail.com> <47EE58E6.4060206@serezhkin.com> In-Reply-To: <47EE58E6.4060206@serezhkin.com> Subject: Re: [Moscow.pm] POE::Filter::Line Date: Sat, 29 Mar 2008 19:34:08 +0400 Message-ID: <589c94400803290834k2650d960p4b326bfb117b12a4@mail.gmail.com> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="----=_NextPart_000_0080_01C89322.221DF960" X-Mailer: Microsoft Office Outlook 12.0 List-Unsubscribe: <http://mail.pm.org/mailman/listinfo/moscow-pm>, <mailto:moscow-pm-request@pm.org?subject=unsubscribe> List-Help: <mailto:moscow-pm-request@pm.org?subject=help> List-Subscribe: <http://mail.pm.org/mailman/listinfo/moscow-pm>, <mailto:moscow-pm-request@pm.org?subject=subscribe> Thread-Index: AciRsmLtKVvo9PgzSTOwLxTpct28Tg== Это составное сообщение в формате MIME. ------=_NextPart_000_0080_01C89322.221DF960 Content-Type: multipart/alternative; boundary="----=_NextPart_001_0081_01C89322.221DF960" ------=_NextPart_001_0081_01C89322.221DF960 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable =D1=82=D0=B0=D0=BC =D0=BE=D1=88=D0=B8=D0=B1=D0=BA=D0=B0 = =D0=B7=D0=B0=D0=BA=D1=80=D0=B0=D0=BB=D0=B0=D1=81=D1=8C. = =D0=9F=D0=BE=D0=BF=D1=80=D0=B1=D1=83=D0=B9=D1=82=D0=B5 = =D0=B2=D0=BE=D1=82 =D1=82=D0=B0=D0=BA=D0=BE=D0=B9 = =D0=B2=D0=B0=D1=80=D0=B8=D0=B0=D0=BD=D1=82. =D0=BC=D0=BD=D0=B5 =D0=BD=D1=83=D0=B6=D0=BD=D0=BE = =D1=83=D0=B1=D0=B5=D0=B3=D0=B0=D1=82=D1=8C. 2008/3/29 Ivan B. Serezhkin <ivan@serezhkin.com>: > Ruslan Zakirov wrote: > > =D0=9C=D0=BE=D0=B6=D0=BD=D0=BE =D1=84=D0=B0=D0=B9=D0=BB=D0=BE=D0=BC = =D0=BF=D0=BE=D0=BB=D1=83=D1=87=D0=B8=D1=82=D1=8C =D0=B5=D1=82=D0=BE = =D0=B4=D0=B5=D0=BB=D0=BE. =D0=A7=D1=82=D0=BE=D0=B1=D1=8B = =D1=84=D0=BE=D1=80=D0=BC=D0=B0=D1=82=D0=B8=D1=80=D0=BE=D0=B2=D0=B0=D0=BD=D0= =B8=D0=B5 =D0=BD=D0=B5 =D0=B1=D0=B8=D0=BB=D0=BE=D1=81=D1=8C. > > > > On Sat, Mar 29, 2008 at 5:43 PM, Ivan B. Serezhkin = <ivan@serezhkin.com> wrote: > > > >> =D0=9F=D1=80=D0=B8=D0=B2=D0=B5=D1=82. > >> > >> =D0=92 =D0=BF=D1=80=D0=BE=D1=88=D0=BB=D0=BE=D0=BC = =D0=BF=D0=B8=D1=81=D1=8C=D0=BC=D0=B5 = =D0=BD=D0=B0=D0=B2=D1=80=D0=B0=D0=BB, = =D0=B2=D0=BC=D0=B5=D1=81=D1=82=D0=BE = =D0=B8=D0=BD=D0=B4=D0=B5=D0=BA=D1=81=D0=B0 = =D0=BE=D0=BF=D1=8F=D1=82=D1=8C = =D0=B7=D0=B0=D0=BC=D0=B5=D1=80=D0=B8=D0=BB = =D1=80=D0=B5=D0=B3=D0=B5=D0=BA=D1=81. > >> > >> Rate Line Index Regexp > >> Line 4.78/s -- -88% -96% > >> Index 39.4/s 725% -- -64% > >> Regexp 109/s 2191% 178% -- > >> > > > -- > Ivan B. Serezhkin > > > #!/usr/bin/perl > # -*- Encoding: utf-8; Mode: cperl -*- > use strict; > use utf8; > use Storable qw(freeze dclone); > use Benchmark qw(:all) ; > use POE::Filter::Line; > > my @s=3Dmap {join '', map { 'SEPARATOR'.'data'x(100+int(rand(100))) } = (1..100)} (1..10); > > cmpthese(100, { > Regexp =3D> sub { > my $data=3Ddclone(\@s); > my $f=3DPOE::Filter::Regexp->new(qr/SEPARATOR/); > $f->get($data); > }, > Index =3D> sub { > my $data=3Ddclone(\@s); > my $f=3DPOE::Filter::Index->new(qr/SEPARATOR/); > $f->get($data); > }, > Line =3D> sub { > my $data=3Ddclone(\@s); > my $f=3DPOE::Filter::Line->new(InputRegexp =3D> = qr/SEPARATOR/); > $f->get($data); > }, > }); > > > > > > > > > package POE::Filter::Regexp; > use strict; > use vars qw($VERSION); > > $VERSION=3D'Production 1.0'; > > sub new { > my ($class,$re)=3D@_; > $re ||=3D qr/\n/; > die "Param in new must be a Regexp but this is a ".ref($re) unless = ref $re eq 'Regexp'; > return bless [ > [], # ready queue > '', # raw unparsed data > $re, > ], $class; > } > > sub get { > my ($self, $stream) =3D @_; > my @ret; > while($_=3Dshift @$stream){ > $self->[1].=3D$_; > $_=3D''; #yah we'r cl'r mems !!!111 > my $p=3D0; > while($self->[1]=3D~/$self->[2]/gm) { > next unless $-[0]; #begin of stream > push @ret, substr($self->[1], $p, $-[0]-$p); > $p=3D$-[0]; > } > substr($self->[1], 0, $p)=3D''; > } > $self->[1]=3D''.$self->[1]; #Clean holes in string. > return \@ret; > } > > > > > package POE::Filter::Index; > use strict; > use vars qw($VERSION); > > $VERSION=3D'Devel'; > > sub new { > my ($class,$sep)=3D@_; > $sep ||=3D "\n"; > return bless [ > [], # ready queue > '', # raw unparsed data > $sep, > ], $class; > } > > sub get { > my ($self, $stream) =3D @_; > my @ret; > while($_=3Dshift @$stream){ > $self->[1].=3D$_; > $_=3D''; #yah we'r cl'r mems 4 4ture iterations !!!111 one one > my $b=3D0; #base > my $p; > while(($p=3Dindex($self->[1], $self->[2], $b+1)) >0) { > push @ret, substr($self->[1], $b, $p-$b); > $b=3D$p; > } > substr($self->[1], 0, $b)=3D''; > } > $self->[1]=3D''.$self->[1]; #Clean holes in string. > return \@ret; > } > > -- > Moscow.pm mailing list > moscow-pm@pm.org | http://moscow.pm.org > http://mail.pm.org/mailman/listinfo/moscow-pm > --=20 Best regards, Ruslan. ------=_NextPart_001_0081_01C89322.221DF960 Content-Type: text/html; boundary="----=_Part_22289_3245532.1206804848542"; charset="UTF-8" Content-Transfer-Encoding: quoted-printable <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN"> <HTML> <HEAD> <META HTTP-EQUIV=3D"Content-Type" CONTENT=3D"text/html; = charset=3Dutf-8"> <META NAME=3D"Generator" CONTENT=3D"MS Exchange Server version = 08.00.0681.000"> <TITLE>Re: [Moscow.pm] POE::Filter::Line</TITLE> </HEAD> <BODY> <!-- Converted from text/plain format --> <P>=D1=82=D0=B0=D0=BC =D0=BE=D1=88=D0=B8=D0=B1=D0=BA=D0=B0 = =D0=B7=D0=B0=D0=BA=D1=80=D0=B0=D0=BB=D0=B0=D1=81=D1=8C. = =D0=9F=D0=BE=D0=BF=D1=80=D0=B1=D1=83=D0=B9=D1=82=D0=B5 = =D0=B2=D0=BE=D1=82 =D1=82=D0=B0=D0=BA=D0=BE=D0=B9 = =D0=B2=D0=B0=D1=80=D0=B8=D0=B0=D0=BD=D1=82. </P> <P>=D0=BC=D0=BD=D0=B5 =D0=BD=D1=83=D0=B6=D0=BD=D0=BE = =D1=83=D0=B1=D0=B5=D0=B3=D0=B0=D1=82=D1=8C. </P> <BR> <P><FONT SIZE=3D2>2008/3/29 Ivan B. Serezhkin = &lt;ivan@serezhkin.com&gt;:</FONT> <BR><FONT SIZE=3D2>&gt; Ruslan Zakirov wrote:</FONT> <BR>&gt;&nbsp; &gt; =D0=9C=D0=BE=D0=B6=D0=BD=D0=BE = =D1=84=D0=B0=D0=B9=D0=BB=D0=BE=D0=BC = =D0=BF=D0=BE=D0=BB=D1=83=D1=87=D0=B8=D1=82=D1=8C =D0=B5=D1=82=D0=BE = =D0=B4=D0=B5=D0=BB=D0=BE. =D0=A7=D1=82=D0=BE=D0=B1=D1=8B = =D1=84=D0=BE=D1=80=D0=BC=D0=B0=D1=82=D0=B8=D1=80=D0=BE=D0=B2=D0=B0=D0=BD=D0= =B8=D0=B5 =D0=BD=D0=B5 =D0=B1=D0=B8=D0=BB=D0=BE=D1=81=D1=8C. <BR><FONT SIZE=3D2>&gt;&nbsp; &gt;</FONT> <BR><FONT SIZE=3D2>&gt;&nbsp; &gt; On Sat, Mar 29, 2008 at 5:43 PM, Ivan = B. Serezhkin &lt;ivan@serezhkin.com&gt; wrote:</FONT> <BR><FONT SIZE=3D2>&gt;&nbsp; &gt;</FONT> <BR>&gt;&nbsp; &gt;&gt; =D0=9F=D1=80=D0=B8=D0=B2=D0=B5=D1=82. <BR><FONT SIZE=3D2>&gt;&nbsp; &gt;&gt;</FONT> <BR>&gt;&nbsp; &gt;&gt;&nbsp; =D0=92 = =D0=BF=D1=80=D0=BE=D1=88=D0=BB=D0=BE=D0=BC = =D0=BF=D0=B8=D1=81=D1=8C=D0=BC=D0=B5 = =D0=BD=D0=B0=D0=B2=D1=80=D0=B0=D0=BB, = =D0=B2=D0=BC=D0=B5=D1=81=D1=82=D0=BE = =D0=B8=D0=BD=D0=B4=D0=B5=D0=BA=D1=81=D0=B0 = =D0=BE=D0=BF=D1=8F=D1=82=D1=8C = =D0=B7=D0=B0=D0=BC=D0=B5=D1=80=D0=B8=D0=BB = =D1=80=D0=B5=D0=B3=D0=B5=D0=BA=D1=81. <BR><FONT SIZE=3D2>&gt;&nbsp; &gt;&gt;</FONT> <BR><FONT SIZE=3D2>&gt;&nbsp; = &gt;&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; = Rate&nbsp;&nbsp; Line&nbsp; Index Regexp</FONT> <BR><FONT SIZE=3D2>&gt;&nbsp; &gt;&gt;&nbsp; Line&nbsp;&nbsp; = 4.78/s&nbsp;&nbsp;&nbsp;&nbsp; --&nbsp;&nbsp; -88%&nbsp;&nbsp; = -96%</FONT> <BR><FONT SIZE=3D2>&gt;&nbsp; &gt;&gt;&nbsp; Index&nbsp; = 39.4/s&nbsp;&nbsp; 725%&nbsp;&nbsp;&nbsp;&nbsp; --&nbsp;&nbsp; = -64%</FONT> <BR><FONT SIZE=3D2>&gt;&nbsp; &gt;&gt;&nbsp; Regexp&nbsp; 109/s&nbsp; = 2191%&nbsp;&nbsp; 178%&nbsp;&nbsp;&nbsp;&nbsp; --</FONT> <BR><FONT SIZE=3D2>&gt;&nbsp; &gt;&gt;</FONT> <BR><FONT SIZE=3D2>&gt;</FONT> <BR><FONT SIZE=3D2>&gt;</FONT> <BR><FONT SIZE=3D2>&gt;&nbsp; --</FONT> <BR><FONT SIZE=3D2>&gt;&nbsp; Ivan B. Serezhkin</FONT> <BR><FONT SIZE=3D2>&gt;</FONT> <BR><FONT SIZE=3D2>&gt;</FONT> <BR><FONT SIZE=3D2>&gt; #!/usr/bin/perl</FONT> <BR><FONT SIZE=3D2>&gt;&nbsp; # -*- Encoding: utf-8; Mode: cperl = -*-</FONT> <BR><FONT SIZE=3D2>&gt;&nbsp; use strict;</FONT> <BR><FONT SIZE=3D2>&gt;&nbsp; use utf8;</FONT> <BR><FONT SIZE=3D2>&gt;&nbsp; use Storable qw(freeze dclone);</FONT> <BR><FONT SIZE=3D2>&gt;&nbsp; use Benchmark qw(:all) ;</FONT> <BR><FONT SIZE=3D2>&gt;&nbsp; use POE::Filter::Line;</FONT> <BR><FONT SIZE=3D2>&gt;</FONT> <BR><FONT SIZE=3D2>&gt;&nbsp; my @s=3Dmap {join '', map { = 'SEPARATOR'.'data'x(100+int(rand(100))) } (1..100)} (1..10);</FONT> <BR><FONT SIZE=3D2>&gt;</FONT> <BR><FONT SIZE=3D2>&gt;&nbsp; cmpthese(100, {</FONT> <BR><FONT = SIZE=3D2>&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;= &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Regexp =3D&gt; sub = {</FONT> <BR><FONT = SIZE=3D2>&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;= &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; = my $data=3Ddclone(\@s);</FONT> <BR><FONT = SIZE=3D2>&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;= &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; = my $f=3DPOE::Filter::Regexp-&gt;new(qr/SEPARATOR/);</FONT> <BR><FONT = SIZE=3D2>&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;= &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; = $f-&gt;get($data);</FONT> <BR><FONT = SIZE=3D2>&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;= &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; },</FONT> <BR><FONT = SIZE=3D2>&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;= &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Index =3D&gt;&nbsp; sub = {</FONT> <BR><FONT = SIZE=3D2>&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;= &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; = my $data=3Ddclone(\@s);</FONT> <BR><FONT = SIZE=3D2>&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;= &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; = my $f=3DPOE::Filter::Index-&gt;new(qr/SEPARATOR/);</FONT> <BR><FONT = SIZE=3D2>&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;= &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; = $f-&gt;get($data);</FONT> <BR><FONT = SIZE=3D2>&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;= &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; },</FONT> <BR><FONT = SIZE=3D2>&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;= &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Line =3D&gt;&nbsp; sub = {</FONT> <BR><FONT = SIZE=3D2>&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;= &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; = my $data=3Ddclone(\@s);</FONT> <BR><FONT = SIZE=3D2>&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;= &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; = my $f=3DPOE::Filter::Line-&gt;new(InputRegexp =3D&gt; = qr/SEPARATOR/);</FONT> <BR><FONT = SIZE=3D2>&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;= &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; = $f-&gt;get($data);</FONT> <BR><FONT = SIZE=3D2>&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;= &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; },</FONT> <BR><FONT = SIZE=3D2>&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;= &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; });</FONT> <BR><FONT SIZE=3D2>&gt;</FONT> <BR><FONT SIZE=3D2>&gt;</FONT> <BR><FONT SIZE=3D2>&gt;</FONT> <BR><FONT SIZE=3D2>&gt;</FONT> <BR><FONT SIZE=3D2>&gt;</FONT> <BR><FONT SIZE=3D2>&gt;</FONT> <BR><FONT SIZE=3D2>&gt;</FONT> <BR><FONT SIZE=3D2>&gt;</FONT> <BR><FONT SIZE=3D2>&gt;&nbsp; package POE::Filter::Regexp;</FONT> <BR><FONT SIZE=3D2>&gt;&nbsp; use strict;</FONT> <BR><FONT SIZE=3D2>&gt;&nbsp; use vars qw($VERSION);</FONT> <BR><FONT SIZE=3D2>&gt;</FONT> <BR><FONT SIZE=3D2>&gt;&nbsp; $VERSION=3D'Production 1.0';</FONT> <BR><FONT SIZE=3D2>&gt;</FONT> <BR><FONT SIZE=3D2>&gt;&nbsp; sub new {</FONT> <BR><FONT SIZE=3D2>&gt;&nbsp;&nbsp;&nbsp;&nbsp; my = ($class,$re)=3D@_;</FONT> <BR><FONT SIZE=3D2>&gt;&nbsp;&nbsp;&nbsp;&nbsp; $re ||=3D qr/\n/;</FONT> <BR><FONT SIZE=3D2>&gt;&nbsp;&nbsp;&nbsp;&nbsp; die &quot;Param in new = must be a Regexp but this is a &quot;.ref($re) unless ref $re eq = 'Regexp';</FONT> <BR><FONT SIZE=3D2>&gt;&nbsp;&nbsp;&nbsp;&nbsp; return bless [</FONT> <BR><FONT = SIZE=3D2>&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;= &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; [], # ready = queue</FONT> <BR><FONT = SIZE=3D2>&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;= &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; '', # raw unparsed = data</FONT> <BR><FONT = SIZE=3D2>&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;= &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; $re,</FONT> <BR><FONT = SIZE=3D2>&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;= &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ], $class;</FONT> <BR><FONT SIZE=3D2>&gt;&nbsp; }</FONT> <BR><FONT SIZE=3D2>&gt;</FONT> <BR><FONT SIZE=3D2>&gt;&nbsp; sub get {</FONT> <BR><FONT SIZE=3D2>&gt;&nbsp;&nbsp;&nbsp;&nbsp; my ($self, $stream) =3D = @_;</FONT> <BR><FONT SIZE=3D2>&gt;&nbsp;&nbsp;&nbsp;&nbsp; my @ret;</FONT> <BR><FONT SIZE=3D2>&gt;&nbsp;&nbsp;&nbsp;&nbsp; while($_=3Dshift = @$stream){</FONT> <BR><FONT SIZE=3D2>&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; = $self-&gt;[1].=3D$_;</FONT> <BR><FONT SIZE=3D2>&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; = $_=3D''; #yah we'r cl'r mems !!!111</FONT> <BR><FONT SIZE=3D2>&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; = my $p=3D0;</FONT> <BR><FONT SIZE=3D2>&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; = while($self-&gt;[1]=3D~/$self-&gt;[2]/gm) {</FONT> <BR><FONT = SIZE=3D2>&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;= &nbsp;&nbsp; next unless $-[0]; #begin of stream</FONT> <BR><FONT = SIZE=3D2>&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;= &nbsp;&nbsp; push @ret, substr($self-&gt;[1], $p, $-[0]-$p);</FONT> <BR><FONT = SIZE=3D2>&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;= &nbsp;&nbsp; $p=3D$-[0];</FONT> <BR><FONT SIZE=3D2>&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; = }</FONT> <BR><FONT SIZE=3D2>&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; = substr($self-&gt;[1], 0, $p)=3D'';</FONT> <BR><FONT SIZE=3D2>&gt;&nbsp;&nbsp;&nbsp;&nbsp; }</FONT> <BR><FONT SIZE=3D2>&gt;&nbsp;&nbsp;&nbsp;&nbsp; = $self-&gt;[1]=3D''.$self-&gt;[1]; #Clean holes in string.</FONT> <BR><FONT SIZE=3D2>&gt;&nbsp;&nbsp;&nbsp;&nbsp; return \@ret;</FONT> <BR><FONT SIZE=3D2>&gt;&nbsp; }</FONT> <BR><FONT SIZE=3D2>&gt;</FONT> <BR><FONT SIZE=3D2>&gt;</FONT> <BR><FONT SIZE=3D2>&gt;</FONT> <BR><FONT SIZE=3D2>&gt;</FONT> <BR><FONT SIZE=3D2>&gt;&nbsp; package POE::Filter::Index;</FONT> <BR><FONT SIZE=3D2>&gt;&nbsp; use strict;</FONT> <BR><FONT SIZE=3D2>&gt;&nbsp; use vars qw($VERSION);</FONT> <BR><FONT SIZE=3D2>&gt;</FONT> <BR><FONT SIZE=3D2>&gt;&nbsp; $VERSION=3D'Devel';</FONT> <BR><FONT SIZE=3D2>&gt;</FONT> <BR><FONT SIZE=3D2>&gt;&nbsp; sub new {</FONT> <BR><FONT SIZE=3D2>&gt;&nbsp;&nbsp;&nbsp;&nbsp; my = ($class,$sep)=3D@_;</FONT> <BR><FONT SIZE=3D2>&gt;&nbsp;&nbsp;&nbsp;&nbsp; $sep ||=3D = &quot;\n&quot;;</FONT> <BR><FONT SIZE=3D2>&gt;&nbsp;&nbsp;&nbsp;&nbsp; return bless [</FONT> <BR><FONT = SIZE=3D2>&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;= &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; [], # ready = queue</FONT> <BR><FONT = SIZE=3D2>&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;= &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; '', # raw unparsed = data</FONT> <BR><FONT = SIZE=3D2>&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;= &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; $sep,</FONT> <BR><FONT = SIZE=3D2>&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;= &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ], $class;</FONT> <BR><FONT SIZE=3D2>&gt;&nbsp; }</FONT> <BR><FONT SIZE=3D2>&gt;</FONT> <BR><FONT SIZE=3D2>&gt;&nbsp; sub get {</FONT> <BR><FONT SIZE=3D2>&gt;&nbsp;&nbsp;&nbsp;&nbsp; my ($self, $stream) =3D = @_;</FONT> <BR><FONT SIZE=3D2>&gt;&nbsp;&nbsp;&nbsp;&nbsp; my @ret;</FONT> <BR><FONT SIZE=3D2>&gt;&nbsp;&nbsp;&nbsp;&nbsp; while($_=3Dshift = @$stream){</FONT> <BR><FONT SIZE=3D2>&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; = $self-&gt;[1].=3D$_;</FONT> <BR><FONT SIZE=3D2>&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; = $_=3D''; #yah we'r cl'r mems 4 4ture iterations !!!111 one one</FONT> <BR><FONT SIZE=3D2>&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; = my $b=3D0; #base</FONT> <BR><FONT SIZE=3D2>&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; = my $p;</FONT> <BR><FONT SIZE=3D2>&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; = while(($p=3Dindex($self-&gt;[1], $self-&gt;[2], $b+1)) &gt;0) {</FONT> <BR><FONT = SIZE=3D2>&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;= &nbsp;&nbsp; push @ret, substr($self-&gt;[1], $b, $p-$b);</FONT> <BR><FONT = SIZE=3D2>&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;= &nbsp;&nbsp; $b=3D$p;</FONT> <BR><FONT SIZE=3D2>&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; = }</FONT> <BR><FONT SIZE=3D2>&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; = substr($self-&gt;[1], 0, $b)=3D'';</FONT> <BR><FONT SIZE=3D2>&gt;&nbsp;&nbsp;&nbsp;&nbsp; }</FONT> <BR><FONT SIZE=3D2>&gt;&nbsp;&nbsp;&nbsp;&nbsp; = $self-&gt;[1]=3D''.$self-&gt;[1]; #Clean holes in string.</FONT> <BR><FONT SIZE=3D2>&gt;&nbsp;&nbsp;&nbsp;&nbsp; return \@ret;</FONT> <BR><FONT SIZE=3D2>&gt;&nbsp; }</FONT> <BR><FONT SIZE=3D2>&gt;</FONT> <BR><FONT SIZE=3D2>&gt; --</FONT> <BR><FONT SIZE=3D2>&gt;&nbsp; Moscow.pm mailing list</FONT> <BR><FONT SIZE=3D2>&gt;&nbsp; moscow-pm@pm.org | <A = HREF=3D"http://moscow.pm.org">http://moscow.pm.org</A></FONT> <BR><FONT SIZE=3D2>&gt;&nbsp; <A = HREF=3D"http://mail.pm.org/mailman/listinfo/moscow-pm">http://mail.pm.org= /mailman/listinfo/moscow-pm</A></FONT> <BR><FONT SIZE=3D2>&gt;</FONT> </P> <BR> <BR> <P><FONT SIZE=3D2>-- </FONT> <BR><FONT SIZE=3D2>Best regards, Ruslan.</FONT> </P> </BODY> </HTML> ------=_NextPart_001_0081_01C89322.221DF960-- ------=_NextPart_000_0080_01C89322.221DF960 Content-Type: application/x-perl; name="poe_filter_split2.pl" Content-Transfer-Encoding: quoted-printable Content-Disposition: attachment; filename="poe_filter_split2.pl" #!/usr/bin/perl=0A= # -*- Encoding: utf-8; Mode: cperl -*-=0A= use strict;=0A= use utf8;=0A= use Storable qw(freeze dclone);=0A= use Benchmark qw(:all) ;=0A= use POE::Filter::Line;=0A= =0A= my @s=3Dmap {join '', map { 'SEPARATOR'.'data'x(100+int(rand(100))) } = (1..100)} (1..10);=0A= =0A= #use Data::Dumper;=0A= #$Data::Dumper::Perlqq =3D 1;=0A= #print Dumper(POE::Filter::Index->new('SEPARATOR')->get(dclone(\@s)));=0A= =0A= cmpthese(-2, {=0A= Regexp =3D> sub {=0A= my $data=3Ddclone(\@s);=0A= my $f=3DPOE::Filter::Regexp->new(qr/SEPARATOR/);=0A= $f->get($data);=0A= },=0A= Index =3D> sub {=0A= my $data=3Ddclone(\@s);=0A= my $f=3DPOE::Filter::Index->new('SEPARATOR');=0A= $f->get($data);=0A= },=0A= Line =3D> sub {=0A= my $data=3Ddclone(\@s);=0A= my $f=3DPOE::Filter::Line->new(InputRegexp =3D> = qr/SEPARATOR/);=0A= $f->get($data);=0A= },=0A= });=0A= =0A= =0A= =0A= =0A= =0A= =0A= =0A= =0A= package POE::Filter::Regexp;=0A= use strict;=0A= use vars qw($VERSION);=0A= =0A= $VERSION=3D'Production 1.0';=0A= =0A= sub new {=0A= my ($class,$re)=3D@_;=0A= $re ||=3D qr/\n/;=0A= die "Param in new must be a Regexp but this is a ".ref($re) unless = ref $re eq 'Regexp';=0A= return bless [=0A= [], # ready queue=0A= '', # raw unparsed data=0A= $re,=0A= ], $class;=0A= }=0A= =0A= sub get {=0A= my ($self, $stream) =3D @_;=0A= my @ret;=0A= while($_=3Dshift @$stream){=0A= $self->[1].=3D$_;=0A= $_=3D''; #yah we'r cl'r mems !!!111=0A= my $p=3D0;=0A= while($self->[1]=3D~/$self->[2]/gm) {=0A= next unless $-[0]; #begin of stream=0A= push @ret, substr($self->[1], $p, $-[0]-$p);=0A= $p=3D$-[0];=0A= }=0A= substr($self->[1], 0, $p)=3D'';=0A= }=0A= $self->[1]=3D''.$self->[1]; #Clean holes in string.=0A= return \@ret;=0A= }=0A= =0A= =0A= =0A= =0A= package POE::Filter::Index;=0A= use strict;=0A= use vars qw($VERSION);=0A= =0A= $VERSION=3D'Devel';=0A= =0A= sub new {=0A= my ($class,$sep)=3D@_;=0A= $sep ||=3D "\n";=0A= return bless [=0A= [], # ready queue=0A= '', # raw unparsed data=0A= $sep,=0A= ], $class;=0A= }=0A= =0A= sub get {=0A= my ($self, $stream) =3D @_;=0A= my @ret;=0A= while(@$stream){=0A= $self->[1].=3Dshift @$stream;=0A= my $p;=0A= while(($p=3Dindex($self->[1], $self->[2], 1)) >0) {=0A= push @ret, substr($self->[1], 0, $p, "");=0A= }=0A= }=0A= return \@ret;=0A= }=0A= =0A= ------=_NextPart_000_0080_01C89322.221DF960 Content-Type: text/plain; name="ATT00071.txt" Content-Transfer-Encoding: quoted-printable Content-Disposition: attachment; filename="ATT00071.txt" --=0A= Moscow.pm mailing list=0A= moscow-pm@pm.org | http://moscow.pm.org=0A= http://mail.pm.org/mailman/listinfo/moscow-pm ------=_NextPart_000_0080_01C89322.221DF960-- ]