|Syntactic Confectionery Delight|
Configuration Files and Template::Toolkit2by Skeeve (Vicar)
|on Jun 04, 2012 at 05:37 UTC||Need Help??|
I don't know whether I had a brand new idea or whether this has already been done.
I have the requirement to generate several report mails. For this I collect some data from some input files and generate mails to certain persons based on this data. The content of this mail is generated by Template::Toolkit2 data.
So what I required is some configuration information for:
My first intention was to use one of the Config::XXX modules. But when I came to the mail templates, I remembered something about T::T2: First level variables are copied and can't be changed, but the structures they point to can be changed. So my T::T2 mail templates look something like this:
So when invoking the $tt->process, I supply in my variables the "Mail" variable, pointing to an empty hash, and I will receive all the values set in the template:
Now I use this approach additionally for my configuration file:
The only things I do is then to invoke that template:
After that I have all my data in the %$config hash.