in reply to printing html entities

There are two basic ways around this. The first is to use the html special characters for this, &lt and &gt, for < and > respectively. The other solution is to enclose the entire block in a <xmp> block, the contents of which are displayed as-is.

Updated: Brain fart. I meant xmp instead of pre. Really. I did. :)

Replies are listed 'Best First'.
RE: Re: html
by perlmonkey (Hermit) on May 23, 2000 at 09:22 UTC
    The second part is not correct. <PRE></PRE> will still interpret the <iostream.h>

    Use a <XMP> block or since this is permonks:
    $code =~ s/>/&gt;/g; $code =~ s/</&lt;/g;
      Or, just use HTML::Entities from the LWP library. You do have that installed, don't you?
RE: Re: html
by swiftone (Curate) on May 23, 2000 at 19:16 UTC
    Make sure you use the semicolon after the &gt; and &lt; tags. Some older browsers will not parse them without them.
      Or some new ones =) The spec for those codes says that the ";" is needed unless the ampersand and codestring are followed by whitespace or other character illegal in a codestring. That means that <html> always works, <html> is wrong since <h may someday mean something and then which do you choose? IE tries to find a working match down the string which is nice but breaks in the future and shows the wrong tag. It has also taught a half million people to do it wrong and then yell at the NS and Opera people.