To figure out which part of your perl script is taking most of the time, you can "profile" your script.
I recently came across a blog by Jerome Quelin on how to profile your perl script using the nytprof profiler.
It's very easy to do this, you just type:
% perl -d:NYTProf script.pl
where script.pl is your perl script.
You then type:
This makes a directory called "nytprof" in which you will find a file "index.html".
If you look at the index.html file in a web browser, you will see a nice breakdown of which of how much time is spent in each subroutine of your perl script.
Here is what the output looks like, in this case the output for my perl script run_genewisedb_afterblast.pl:
This is very handy for pinning down which bit of your code is taking up the most compute time, to help you think how you could speed it up.