in reply to Nested loops of doom

If you want to speed up your code, you need to find out what's taking up the most time. The way to do that is to use a profiler, probably on a reduced-size run. You can try Devel::DProf, Devel::Profile or perhaps Devel::SmallProf.

Once you know where the time is being spent you can work on finding a faster way to do it. You could post again with a more specific question, revealing perhaps what's actually done in the middle of your innermost loop.

-sam