![]() |
|
Perl-Sensitive Sunglasses | |
PerlMonks |
Re^2: Import Constants From File to Templates? (introspect current constants) (updated)by LanX (Sage) |
on Dec 04, 2021 at 15:04 UTC ( #11139388=note: print w/replies, xml ) | Need Help?? |
> 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. Jeez, that was harder than I thought. Perl is also storing constants as scalar-refs if no glob is needed for other slots. (NB: I'm now returning a hash-ref)
updatejust read again > I'd like to include those constants in all my templates directly from my constants module rather than importing them to my script and then remembering to set the ones I need each time I process a template. Well I don't know how to globally include constants into all TT templates, but please note that my solution to find doesn't require to import them first. Just change the sub to get the $pkg origin from an argument instead from caller..
Cheers Rolf
In Section
Seekers of Perl Wisdom
|
|