rebel Posted December 30, 2004 Posted December 30, 2004 hi there, simple question: what is the perl equivalent of the following lines? <?php header('Content-type: text/plain; charset=utf-8'); header('Content-disposition: attachment; filename=output.txt'); print 'hello world'; ?> actually, to be more specific, what's the perl equivalent of the second line? in the actual code that is i've looked in a couple of places on the net but came up with nothing so far..... thanks and have a great new year Quote
HCSuperStores Posted December 30, 2004 Posted December 30, 2004 I'll try to help ... but forgive me if I'm not answering your question exactly. This is, I think, what you are looking for. #!/usr/bin/perl use CGI; use CGI::Carp qw(fatalsToBrowser); print "Content-type: text/html\n\n"; print "Hello World"; exit; The lines in blue are optional but recommended. Be sure your script has been uploaded in ASCII format (v.s. binary) and that the permissions are set to 755. If you need more clarification on this, send me an e-mail to be sure I see it. Good luck! Quote
rebel Posted December 30, 2004 Author Posted December 30, 2004 thanks for the reply, but that's not what i'm looking for unfortunately. your code will print the text to the browser, but that's not what i want. if you try the php code, the output should be in a file called 'output.txt' and the user will be prompted to either save the file or open it. i thought there'd be a way using the CGI header, perhaps something like this.... print header(-type=>'text/plain', charset=>'utf-8', disposition=>'attachment', filename=>'output.txt'); but i haven't found it so far. basically i'm too lazy to select, copy, paste and save the output and i want to just be able to save it all in one step. Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.