in reply to Performance issue

If you want to know which parts of your code consume the time, remove your print time lines and instead use a profiler like Devel::NYTProf.

Then you can start optimizing.