in reply to Injecting local variables into a template
You could look to see how Template::Stash does it. Besides the POD there are comments in the code describing how each function works.