We don't bite newbies here... much | |
PerlMonks |
Re: Performance issueby graff (Chancellor) |
on Feb 18, 2009 at 14:49 UTC ( [id://744775]=note: print w/replies, xml ) | Need Help?? |
Apart from the timing issue (where I think previous replies have been very helpful), I'd point out that your "Extract" sub really does not make sense as a subroutine. It receives and declares variables that are never used, and uses/alters variables that must be global in scope (because they're never declared) -- bad form in both cases.
You might want to get acquainted with Benchmark, and then maybe use that to compare alternate approaches. To use it effectively, you'll want to rethink your subroutine so that it's more "atomic" (independent, modular), which will be a Good Thing. You might also consider split as an alternative to regex matching with captures. Based on the data shown, something like this would suffice: I don't recall off-hand what sort of timing difference this might yield (but Benchmark would be a good way to find out). Maybe the stuff that your "Extract" sub is doing could be done without a sub call, and that might save some time (along with getting rid of the unnecessary print statements).
In Section
Seekers of Perl Wisdom
|
|