I tried to decypher your code but I give up. It is simply unreadable mess. I doubt you will understand it yourself after a week. Some hints:
- Use strict and warnings
- Use human readable variable names. When I see $n, $m, etc it say me nothing.
- Split large code chunks on subroutines with human readable names.
- Don't use exotic Perl features just because you can (i.e. code refs in @INC to convert templating language in Perl code on fly). There are much simplier ways to do the same thing (compile template in Perl code). Take a look on existing templaiting modules to see how. BTW probably they already do what you want or can be easily extended to do it.
- If you need to restrict power of Perl expressions you need to use Safe. Parsing Perl code is tricky.
Ilya Martynov, firstname.lastname@example.org
CTO IPonWEB (UK) Ltd
Quality Perl Programming and Unix Support
UK managed @ offshore prices - http://www.iponweb.net
Personal website - http://martynov.org