in reply to Increase speed script

The suggestion from roboticus is a good one.

I'd like to add to that a more general suggestion. When you have a performance problem, there are tools available to help tell where the problem is. Using Devel::DProf or Devel::Profile, you can get profiling data on a per-sub basis. For a tutorial, see Profiling your code.

For something like what you have, where there aren't many subs, just a short program of lines, Devel::NYTProf and Devel::SmallProf are more appropriate tools.

Try them out. You may be surprised at what they show (I usually am).