in reply to Optimizing the bejeezus out of a sub
A number of comments, most of which shouldn't affect performance, but a couple of which might.
- Why are you predeclaring $val, $sec, and $v? Move the declaration inline. I doubt that there is any performance difference but it keeps someone (like me) from wondering whether, for instance, $v is global.
- Try assigning @_ to $ret, then decrement $ret on skipped sections. Theoretically faster, though probably imperceptibly so.
- You could select $fh temporarily rather than printing to it each time.
- Why are you writing your own templating engine? I would be inclined to use one of the many ones out there already, several of which have been optimized far more than I would feel like doing it.
In Section
Seekers of Perl Wisdom