Does XBase have any built in searching or indexing? I'm not familiar with it, so I don't know.
If so, I would definitely prepare a query in Perl and let the database handle it. It ought to be optimized for that sort of thing.
Regardless, there are a few places where you have things inside a loop that don't seem to need to be there. Case in point, checking the query for a certain type, then choosing which keywords to find. Unless the query changes in the middle of the search, you can compute the search elements just once, not once for each row of the database. | [reply] |
Have you tried narrowing down the cases that make the script run wild? Are they always the same queries, or is there no apparent pattern to it?
As far as your code goes, there are several things I feel I should point out.
For starters, you should use: use lib '/Xbase'; instead of your BEGIN block.
Another thing is, why are you using Socket.pm? Maybe I missed something, but I didn't see anything that needed that module
Next off you should be using CGI.pm instead of parsing out form input yourself.
Also, you use /gis on a lot of your matches on a variables, but not sure why. In most cases it seems that matching once would be fine (in an if statement), thus no need for /g, /s if I recall properly (regex gurus correct me if I'm mistaken), makes '.' match a newline (so unless you've got real regex stuff inside those variables, this is probably not what you want.) Which brings to the next thing, your trusting the input to be valid and good (which is really a whole different discussion), at the vary least, to make the regex's work more like expected (again unless you're doing something strange elsewhere that I'm not aware of), you should probably use quotemeta on the variables that you are using as your match pattern.
I'm not really familiar with Xbase or Novell, so I can't tell you what problems you may or may not be having there, but there seems to be a lot of code to clean up no matter where the exact problem lies.
cephas | [reply] |
The module doesn't have searching capabilities -- only read capabilities. I know CGI.pm will do that stuff for me, but I like doing it myself (maybe I'm wierd). The queries don't seem to affect how the script runs (it seems random). Maybe the regexp's could be set up different; I'm not a hardcore perl programmer. If it works, I'm happy. If it doesn't, I try to fix it.
I can't remember why socket.pm is in there. I'm sure there was a good reason for it; it's been too long.
| [reply] |