in reply to Speed Improvement

The first thing to do would be to profile your code, to figure out what takes at lot of time. Try Devel::NYTProf, probably the best profiler available under Perl.