Did you look at Template::Extract?
In reply to Re: Inverting Template::Toolkit by Corion in thread Inverting Template::Toolkit by talexb