I am working with Perl/CGI, MySQL, Perl Template toolkit.
I have a database set up and some perl modules to query the database.
From the perl modules I pass on a datastructure (hash of hashes) to perl template toolkit (.tt) and that renders the results on the webpage.
I would now like to add an option of downloading the search results into a tab delimited file; i.e. provide a download file option. I have a subroutine in my perl module to do the conversion into tab-seperated format. I want to be able to call that subroutine to convert the search results into tab-seperated format. Can I call a subroutine from a perl module in Template toolkit?
I am trying to figure out how to generate a downloadable file without again querying the database or without storing the results in CACHE.
Is there a way to pass the datastructure(hash of hashes) that Perl template is rendering, to a Javascript (that further calls subroutine) that can then generate a downloadble file?
Please suggest a correct approach.
Thanks for your time