CGI/Perl Guide | Learning Center | Forums | Advertise | Login
Site Search: in

  Main Index MAIN
INDEX
Search Posts SEARCH
POSTS
Who's Online WHO'S
ONLINE
Log in LOG
IN

Home: Perl Programming Help: Beginner:
Text File Content Printing?

 



zicero
Deleted

Oct 3, 2000, 5:00 AM

Post #1 of 3 (1102 views)
Text File Content Printing? Can't Post

I can't make it so I print the entire content of a text file.

I open the file and get the data,
but simply can't make it print it to the browser.

Print to the file works fine, ut read from file
and print it jut doesn't work Frown



------------------
http://www.zicero.dk


zicero
Deleted

Oct 3, 2000, 10:26 PM

Post #2 of 3 (1102 views)
Re: Text File Content Printing? [In reply to] Can't Post

Thank you.
That helped and worked.

------------------
http://www.zicero.dk


rGeoffrey
User / Moderator

Oct 4, 2000, 7:52 AM

Post #3 of 3 (1102 views)
Re: Text File Content Printing? [In reply to] Can't Post

Browsers can get really upset if you don't tell them what 'Content-type' to use, or you give them text before the Content-type.

<BLOCKQUOTE><font size="1" face="Arial,Helvetica,sans serif">code:</font><HR>


my $filename = 'textfile.html';
print "Content-type: text/html\n\n";

open (DATA, $filename) or die ("could not open $filename, $!\n");
while (<DATA> ){
print $_;
}
close DATA;
</pre><HR></BLOCKQUOTE>

It you want to print straight text remember to use "Content-type: text/plain\n\n".

Also you can rewrite this without the word 'while', but that is left as an exercise for the reader.

[This message has been edited by rGeoffrey (edited 10-04-2000).]

 
 


Search for (options) Powered by Gossamer Forum v.1.2.0

Web Applications & Managed Hosting Powered by Gossamer Threads
Visit our Mailing List Archives