If your perl code is a CGI or can be made into a CGI easily, then you could save your results from the DBI query into a variable and output it as an appropriate multi-part mime-type etc to force the output to end up going to a browser save as file dialog. sorry can't remember the exact details of forcing this. must be somewhere in the CGI module documentation.