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

Re: [FWP] keyword parser for search engine



Rick <rklement@pacbell.net> writes:
> Given \000 as an available marker, let's twist a little more
> and do this:
> 
> sub locate_glob_to_regex {
>   local $_ = "\000\000" . shift;
>   s/\000\000\*/\000.*\000\000/ or
>     s/\000\000\?/\000.\000\000/ or 
>     /\000\000\\$/ and return(undef) or
>     s/\000\000(\\.|\w+)/$1\000\000/ or
>     /\000\000\[[\!\^]\][^\]]*$/ and return(undef) or
>     s/\000\000\[([\^\!]?)(\].*?)\]/\000[@{[$1 && '^']}$2]\000\000/ or
>     s/\000\000\[([\^\!]?)([^]]+)\]/\000[@{[$1 && '^']}$2]\000\000/ or
>     s/\000\000([^[])/\\$1\000\000/ or return(undef)
>     until s/\000\000$//;
>   $_ = "^$_\$" if tr/\000//d;
>   return qr/$_/;
> }
> 
> By putting the \000 before the replacement, a second marker
> is not needed.

I like the new version, but it's a shame about all the \000 mess.  A simple
`my $z = qr/\000/;' at the top plus a global s/\\000/\$z/ should fix that.

-- 
Aaron Crane   <aaron.crane@pobox.com>   <URL:http://pobox.com/~aaronc/>

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