|P is for Practical|
Re: Up for Critiqueby derby (Abbot)
|on Mar 22, 2002 at 21:16 UTC||Need Help??|
For starters drop the while( $record = <INFILE>) and try the more idiomatic while( <INFILE> ) then use the implicit $_ instead of $record.
Use references to pass into and recieve back from your subroutines. Don't bother initializing them in the calling block:
Also, take a look at your regexes. Try to reduce those to
a more reasonable number
You get the idea. Running multiple regexes against a single line can take forever. Try to reduce the regexes into simpler one(s) that will run once against the line and also ensure you use the 'o' flag so you're not spinning your wheels always compiling the regexes.
But I think all of those type changes are going to have a minimal impact. You really need to concentrate on your dbs performance and whats going on there. I'm not sure about mysql but some database will commit "transactions" so many inserts (does mysql/innodb table do that?). You can set up your drive to make that number larger and reduce the number of commits.
They're may be other stuff but that's just one person's opinion. It's kinda hard to do without being able to run the stuff. Have you tried profiling the script to see where you're spending all your time? At a minimum, you could liberally sprinke Benchmark timings before and after sections of the code and then use timediff to see how long the snippet took.
Good luck. ++ for an interesting post.
update: ferrency is right about the optimizations. sorry for the mislead.