Re: [code-review] URI::Find::Iterator
Yuval Kogman <nothingmuch-JLKJG/[email protected]> Wed, 10 Dec 2003 15:43:39 +0200
| Newsgroups | gmane.comp.lang.perl.code-review-ladder |
|---|---|
| Message-ID | <[email protected]> |
--qMm9M+Fa2AknHoGS
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
Content-Transfer-Encoding: quoted-printable
On Wed, Dec 03, 2003 at 02:29:56PM +0000, Simon Wistow wrote:
> It occured to me that the underlying code could be spun out into =
=20
> Regex::Iterator to provide a generic way to iterate over regexes with =
=20
> U:F:I being a thin shim on top. =
=20
That sounds like a very useful idea.
> I finished the code last night when I found it lying around about 6
> months after doing the initial stab . I'm using a slightly odd mechnism
> for iterating and I should probably try and remember why I did that.
> Again comments welcome.=20
I think you should use \G and pos on the $self->{_remain} value,
instead of $` et al. They are notorious for slowing down regexes.
Read about \G under perlre if you're not familiar. It is a zero width
assertion which matches point in the string indexed by the value pos
(perldoc -f pos) is set to. Every time a global match is made, the pos
value is set to the end of the match.
This is with //g matches in scalar context.
When you're generating regexes, try to set the last variable to be
$var =3D qr/$var whatever .*/;
This way the regex doesn't have to be recompiled each time. You then
just match against the variable:
$_ =3D~ $var;
And including it in a match string isn't painful either, AFAIK:
/$var and something else/;
About the interface:
I think it would be useful if the input could be more arbitrary. I
have a spamtrap, and I use
wget -q -b -o /dev/null -i - -F -O /dev/null --limit-rate=3D3K
--wait=3D3 --random-wait -Q 256K
to hopefully activate all the web bugs. You're module could be useful,
and better purposed, to do this with some more fine grained control.
I think this should also be able to work on a FH reference passed to
it, with remain being the pending input, and match & result behaving
as they do now.
I've never tried matching generic regexes on arbitrary sized
input. With URLs it shouldn't be tough, because they don't have line
breaks in them - you can just match lines.
This will be harder for a generic Regexp::Iterator.
Some feedback about the distribution:
Many people still don't have Module::Build. I think it's nicer to use
create_makefile_pl =3D> "traditional"
instead of "passthrough".
The tests all passed, BTW.
--=20
() Yuval Kogman <nothingmuch-JLKJG/[email protected]> 0xEBD27418 perl hacker &
/\ kung foo master: /me beats up some cheese: neeyah!!!!!!!!!!!!!!!!!
--qMm9M+Fa2AknHoGS
Content-Type: application/pgp-signature
Content-Disposition: inline
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.3 (Darwin)
iD8DBQE/1yMLVCwRwOvSdBgRAk6CAJ0WqlhBrKAJplsN3G3jbowC4fwxGQCgsmdb
lQe/5q8splVJCQUVDuEZzG4=
=GLNM
-----END PGP SIGNATURE-----
--qMm9M+Fa2AknHoGS--