in reply to downloading file with CGI

There's nothing magic about the -attachment header — it's just a hint to the browser to prompt the user to save the content sent by the CGI script (instead of displaying it). But you still have to send the content, i.e. read booklist.csv and print it to STDOUT...

Replies are listed 'Best First'.
Re^2: downloading file with CGI
by Anonymous Monk on Dec 02, 2009 at 19:55 UTC

    well,if I read from file and print it to STDOUT (as suggested) then it prints to the browser itself and dont prompt for download.

      You have to do both, i.e. use the -attachment header and print the content.  The header tells the browser to prompt with "Save [as...]", using the suggested filename as default.