Please forgive me for being mildly off-topic, but I thought I might suggest an alternative for the way you're creating your search() query (using an array). I'm assuming that you're going to be opening a db connect(), running a query for matches, and returning the positives. A lot of people will tell you to let the db perform the heavy work for you. Depending on the size of the table, they may or may not be right.
I recently completed a script to store logfile statistics into a MySQL db (who hasn't), and found that it's actually quicker for me to open the dbh, pull
all of my data out (assuming I only need to search one field), and insert them as keys into a hash (null values). Hashes are incredible for handling massive amounts of similar data. Anyhoo,
then you can perform a simple defined() or exists() on the hash keys for your search criteria (or some regex derivative thereof). My particular application dropped from a runtime of minutes, to just under 7 seconds (comparison/injection of approximately 12000 complex entries).
That said, it's just my $.02. I'm not an expert, it just happened to work well for me... it may not be applicable to your needs, but maybe it will in the future. :-)
Hashes are your friend
-fuzzyping
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.