Hi Pritesh,
> However, the same code is not working under mod_perl. The file
> content is the same as original file, but filename is populated as
> download.cgi instead of actual file name. I think mod_perl is
> putting its own headers, while sending the data.
Are you using the PerlSendHeader On directive in your httpd.conf file?
If not put this into your <Location> section (or whatever) and it
should cure your problem, e.g.
<Location /perl>
SetHandler perl-script
PerlHandler Apache::Registry
PerlSendHeader On
Options +ExecCgi
</Location>
See also the online mod_perl guide
http://perl.apache.org/guide/porting.html#Generating_correct_HTTP_Headers
I hope this helps,
Axel