Jump to content

Recommended Posts

Posted

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..... :eek:

 

thanks and have a great new year

Posted

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!

Posted

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. :D

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...