Gossamer Forum
Home : General : Perl Programming :

A bit confused about headers....

Quote Reply
A bit confused about headers....
I'm using the following code:

Code:
sub main {

my $url = "http://www.wiredon.net/";
my @page = get($url);
print "Content-type: text/plain\n\n";
foreach (@page) {
print;
}

}
Should that not print the HTML?....because it shows the page properly as if you were visiting it with your browser. Using text/plain and text/html both give the same result.

I'm sure in the past when I've used text/plain it has printed the HTML code rather that the page itself.

Installs:http://wiredon.net/gt
FAQ:http://www.perlmad.com

Quote Reply
Re: A bit confused about headers.... In reply to
There's a good article here http://www.webtechniques.com/archives/1997/04/webm/ that explains it in some detail. It's a long article, so scroll down to around this article heading:
MIME Types, Helper Applications, and Plug-Ins. Basically text/plain, means it's ASCII text file, and text/html is HTML codes in addition to ASCII text.

Later,
Paul

http://www.fullmoonshining.com for Pearl Jam Fans
Quote Reply
Re: A bit confused about headers.... In reply to
Thanks for the link but I already knew what the different headers were for.

Basically what I'm saying is that my code above DOESN'T print out the ASCII version of the HTML as it should - it keeps showing the html page as normal.

To get around it at the moment I am using:

Code:
s/</&amplt;/g;
...but I shouldn't have to and I can't figure why it isn't doing what it should.

Installs:http://wiredon.net/gt
FAQ:http://www.perlmad.com

Quote Reply
Re: A bit confused about headers.... In reply to
Sorry, I see what you mean now, you want the actual tags printed right? I was under the impression that at least, Internet Explorer, would render the html regardless of the type being text/plain, or text/html. I believe that default type in IE is text/plain, if a type was not sent to the browser. How to display them then. Not sure. That's not much help, but maybe it's a better explanation. I'll hunt around for a better answer, as it is something I would like to know as well.

Later,
Paul

http://www.fullmoonshining.com for Pearl Jam Fans
Quote Reply
Re: A bit confused about headers.... In reply to
Yep you got it. It keeps showing the html rather than printing the tags as ASCII.

Installs:http://wiredon.net/gt
FAQ:http://www.perlmad.com

Quote Reply
Re: A bit confused about headers.... In reply to
I think I've found a solution to your problem. Try putting a <xmp></xmp> around your entire html documents tags. This will force the browser to display the tags rather than rendering them to the page. This should work in Netscape 4.x and IE 5(maybe lower versions but I'm not sure).

Later,
Paul

http://www.fullmoonshining.com for Pearl Jam Fans
Quote Reply
Re: A bit confused about headers.... In reply to
Worked great!

Thanks.....that's weird - I'm sure I've printed html before without using xmp.....ah well - thanks!



Installs:http://wiredon.net/gt
FAQ:http://www.perlmad.com

Quote Reply
Re: A bit confused about headers.... In reply to
No problem. Just a warning. That is an html 3.2 tag and some of the documentation suggests that in the future it may not be supported by some browsers...don't know why though, there's other tags that aren't so useful that are still included. Anyway, just so you know.

Later,
Paul

http://www.fullmoonshining.com for Pearl Jam Fans
Quote Reply
Re: A bit confused about headers.... In reply to
Thanks.

Now onto the tricky part - using different colors to identify different tags....

Installs:http://wiredon.net/gt
FAQ:http://www.perlmad.com

Quote Reply
Re: A bit confused about headers.... In reply to
I think I read somewhere that this is a problem with Internet Explorer.

It just decides to make it's own rules up again, and if it find any HTML tag on a page, it will render the whole page as HTML -- just to piss everyone off <g>.

Wil

Quote Reply
Re: A bit confused about headers.... In reply to
In Reply To:
Now onto the tricky part - using different colors to identify different tags....
But then won't the colour tags just get output as text? Wink

Stick with the &lt; substitution, that's how I did mine: http://144.132.157.127/view_source/


- Mark

Astro-Boy!!
http://www.zip.com.au/~astroboy/
Quote Reply
Re: A bit confused about headers.... In reply to
In Reply To:
But then won't the colour tags just get output as text?
Yeah - that's why it was the tricky part Smile

Thanks for the tip, I'll try with &lt; then.

By the way...it is a pain in the ass getting &lt; to print in a forum post Wink

....you have to use &ampamp;lt;...and then to print that I had to use &ampampamp;lt;...and so on...hehe



Installs:http://wiredon.net/gt
FAQ:http://www.perlmad.com

Quote Reply
Re: A bit confused about headers.... In reply to
Heheh, same with comment tags :)

And then if you edit your post you have to fix everything up again, argh! Smile


- Mark

Astro-Boy!!
http://www.zip.com.au/~astroboy/