C
ccc31807
This is a web front end to a database, served via Apache using SQLite
using CGI.
The key requirement is that the app displays the data to the user and
prints it at the user's request, which happens infrequently.
I can print a document by:
- running a query to get a hash ref
- processing the hashref to get an appropriate data structure
- opening a file
- printing the data structure to a file
- closing the file, and
- returning a link to the file to the user
I can also display the data by:
- running a query to get a hash ref
- processing the hashref to get an appropriate data structure, and
- printing the data structure to the screen
What I need is a button on the display that will allow the user to
print a document using the same hashref. I don't want to run the query
again, and don't particularly want to store the data (using Storable,
perhaps), but to pass the hashref to another page via an HTTP request,
and have the second page open a file, print to the file, close the
file, and return a link to the user.
Unfortunately, the hashref doesn't persist between invocations of the
script and new HTTP requests. For example, I can do this:
<a href="mydata?what=printcsv&data=HASH(0xDEADBEEF)"
target="_blank">Print a file</a>
But all I get is the value 'HASH(0xDEADBEEF)". I can't dereference it
to get at the data.
Seems like I should be able to tell the program to hold onto the
hashref between invocations of the script, but I can't seen to figure
out how. Ideas?
Thanks, CC.
using CGI.
The key requirement is that the app displays the data to the user and
prints it at the user's request, which happens infrequently.
I can print a document by:
- running a query to get a hash ref
- processing the hashref to get an appropriate data structure
- opening a file
- printing the data structure to a file
- closing the file, and
- returning a link to the file to the user
I can also display the data by:
- running a query to get a hash ref
- processing the hashref to get an appropriate data structure, and
- printing the data structure to the screen
What I need is a button on the display that will allow the user to
print a document using the same hashref. I don't want to run the query
again, and don't particularly want to store the data (using Storable,
perhaps), but to pass the hashref to another page via an HTTP request,
and have the second page open a file, print to the file, close the
file, and return a link to the user.
Unfortunately, the hashref doesn't persist between invocations of the
script and new HTTP requests. For example, I can do this:
<a href="mydata?what=printcsv&data=HASH(0xDEADBEEF)"
target="_blank">Print a file</a>
But all I get is the value 'HASH(0xDEADBEEF)". I can't dereference it
to get at the data.
Seems like I should be able to tell the program to hold onto the
hashref between invocations of the script, but I can't seen to figure
out how. Ideas?
Thanks, CC.