I'm no Template::Toolkit expert and and it's not clear to me how you wanna use the constants, since you gave no example°.

I just skimmed thru the docs and found two possible approaches:

Constants in Perl are just implemented as subs with empty prototype

Hence you could write a sub current_constants() which is introspecting your current package and return a list of pairs which maps each constant to it's name. Another way could be to check the exporter settings of the defining package.

my $tt = Template->new({ CONSTANTS => { current_constants() }, });

Once this works you should also be able to write a TT plugin to do this automatically.

Question That's what you want?

update

°) this was written before the OP added his "EDIT" section.

Cheers Rolf
(addicted to the Perl Programming Language :)
Wikisyntax for the Monastery


In reply to Re: Import Constants From File to Templates? by LanX
in thread Import Constants From File to Templates? by varanasi

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.