[Date Prev][Date Next][Thread Prev][Thread Next] [Search] [Date Index] [Thread Index]

Re: [FWP] sifting



On Apr 12, Bennett Todd said:

>Another approach, which appeals to me a bit more, would be like

>	my @categories = qw(ALPHA BETA);
>	my($pat) = qr(@{[join('|', @categories)]});
>	my %cats;
>	/($pat)/ ? push @{$cats{$1}}, $_ : push @rejects, $_ for @input;

This only works on constant regexes.  $1 is not always the string that is
the regex.

A similar implementation (that uses (?{ ... })) is at:

  http://www.pobox.com/~japhy/DALnet-perl/sift/eval-sift

-- 
MIDN 4/C PINYAN, NROTCURPI, US Naval Reserve             japhy@pobox.com
http://www.pobox.com/~japhy/                  http://pinyaj.stu.rpi.edu/
PerlMonth - An Online Perl Magazine            http://www.perlmonth.com/
The Perl Archive - Articles, Forums, etc.    http://www.perlarchive.com/


==== Want to unsubscribe from Fun With Perl?  Well, if you insist...
==== Send email to <fwp-request@technofile.org> with message _body_
====   unsubscribe