Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl: the Markov chain saw
 
PerlMonks  

output a file from perl online

by ecuguru (Monk)
on Aug 29, 2005 at 08:59 UTC ( [id://487361]=perlquestion: print w/replies, xml ) Need Help??

ecuguru has asked for the wisdom of the Perl Monks concerning the following question:

In my perl script online I have:
#!/usr/bin/perl print <<"APPDATA"; Content-type: application/dat #...
My apache server is setup to handle .dat files as application files that need to be downloaded. My perl script will send the data file, but the file is named the same as my perl script. I'd like to be able to define the name of the file that gets downloaded. Can someone tell me how I can pick the name of the output file that gets sent to the browser?
Thanks!

Replies are listed 'Best First'.
Re: output a file from perl online
by holli (Abbot) on Aug 29, 2005 at 09:29 UTC
    You have to send the files name in the HTTP-header:
    Content-Disposition: Attachment; filename=somefile.dat


    holli, /regexed monk/
      Worked perfect, thanks!
      print <<"THANKS"; Content-Type: application/kml; charset=us-ascii Content-Disposition: attachment; filename="attach.dat"\n\n
Re: output a file from perl online
by Roger (Parson) on Aug 29, 2005 at 12:36 UTC
    I recommend you to have a look at the CGI module to do simple html programming, instead of hand coding HTML headers and tags. The answer to your question can be located under the heading CREATING A STANDARD HTTP HEADER. It has several examples underneath to do what you after.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://487361]
Approved by Zaxo
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others taking refuge in the Monastery: (7)
As of 2024-04-18 02:59 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found