|XP is just a number|
Re: Huge simple problemby dreadpiratepeter (Priest)
|on Aug 05, 2009 at 22:43 UTC||Need Help??|
May I suggest that you learn to use the foreach loop in Perl, rather than the c-style for loop.
and in a loop this simple I would just use $_
or reduce it even further with a map and a join (depends on circumstance, if I'm the not only maintainer I'd probably use the above version)
all the above code is untested.
update: also you could first clean the ends of $query (with s/^\s*(.*?)\s*$/). Then if you change the slip condition to /\s*(?:and|or)\s*/ you can skip the map:
of course at this point you can skip the whole split and use:
A final note, all these will fail horribly if your data has and/or imbedded in words. ie world. You probably want to split on /\s+(?:and|or)\s+/ or /\s*\b(?:and|or)\b\s*/
Phew, now I need a nap
"Worry is like a rocking chair. It gives you something to do, but it doesn't get you anywhere."