$headers_hash->{'Content-disposition'} = "attachment; filename=" . $re +port_name . ".csv";
If your filename contains "weird" characters, you should best put double quotes around the filename. And Perl has powerful string interpolation syntax features, so you don't have to concatenate all the loose parts yourself. It makes code just a little bit more tidy.
$headers_hash->{'Content-disposition'} = "attachment; filename=\"$repo +rt_name\".csv";
In case you wish to embed double quotes, it may be beneficial to use qq with any delimiter or delimiter pair you like, so you can drop the backslashes:
$headers_hash->{'Content-disposition'} = qq(attachment; filename="$rep +ort_name".csv);

Also, be aware that there's no way to force a browser to dowload a file, all you can do is make a polite request. It's the browser itself, and the user behind the keyboard, that has the final word. See the late Alan J. Flavell's view on this matter, a view shared by many other experts, in the last post in this thread:

The original idea of the interworking protocols was that it was the *recipient's* business to decide whether they wanted to render a resource or to download it. The author/publisher's job was just to advertise its content-type honestly (as you note). The idea of a mischievous author proposing a download, to some sensitive file on the recipient's system, and the naive user acceding to the request, is just too attractive to a certain kind of pondlife on the 'net.

Re: the subject line: generally speaking, "force" does not work, on the WWW. And it's good that it is so.


In reply to Re: Problem In generating the CSV file in the perl code using Apache by bart
in thread Problem In generating the CSV file in the perl code using Apache by sondagar_nilesh

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.