If it is really O(n^n) and n is anything greater than about 10, then you are stuffed.
Describe what you are trying to achieve and show us the guts of the code with a very small sample set. We may be able to advise on a better technique than you are currently using. Consider this thread as an example of how a different approach can help.
In reply to Re: out of memory problem
by GrandFather
in thread out of memory problem
by perlbeginner10
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |