in reply to Parse template into data structure

Hmmm...I think the solution might not be that obvious. (especially once you start to worry about more complex constructs within the template, such as IFs etc).

Here's a sneaky thought - run the template, but give it a tied hash which traps and output the key on each attempted access to a hash value. You'll still miss any hash keys which are conditionally accessed, but it should do as a good first run.

Looks like Tie::Trace might do the job nicely.