The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.
<HTML>
<HEAD>
  <TITLE>HTML::Stream 1.54</TITLE>
</HEAD>
<BODY 
       bgcolor="#FFFFFF" link="#CC3366" vlink="#993366" alink="#FF6666">
<FONT FACE="sans-serif" SIZE=-1><A HREF="http://www.zeegee.com" TARGET="_top"><IMG SRC="icons/zeegee.gif" ALT="ZeeGee Software" ALIGN="RIGHT" BORDER="0"></A><A NAME="__TOP__"><H1>HTML::Stream 1.54</H1>
</A><UL>
<LI> <A NAME="menu:NAME"><A HREF="#NAME">NAME</A></A>
<LI> <A NAME="menu:SYNOPSIS"><A HREF="#SYNOPSIS">SYNOPSIS</A></A>
<LI> <A NAME="menu:DESCRIPTION"><A HREF="#DESCRIPTION">DESCRIPTION</A></A>
<LI> <A NAME="menu:INTRODUCTION_the_Neapolitan_dessert_special"><A HREF="#INTRODUCTION_the_Neapolitan_dessert_special">INTRODUCTION (the Neapolitan dessert special)</A></A>
<UL>
<LI> <A NAME="menu:Function_interface"><A HREF="#Function_interface">Function interface</A></A>
<LI> <A NAME="menu:OO_interface_vanilla"><A HREF="#OO_interface_vanilla">OO interface, vanilla</A></A>
<LI> <A NAME="menu:OO_interface_chocolate"><A HREF="#OO_interface_chocolate">OO interface, chocolate</A></A>
<LI> <A NAME="menu:OO_interface_with_whipped_cream"><A HREF="#OO_interface_with_whipped_cream">OO interface, with whipped cream</A></A>
<LI> <A NAME="menu:OO_interface_strawberry"><A HREF="#OO_interface_strawberry">OO interface, strawberry</A></A>
</UL>
<LI> <A NAME="menu:ADVANCED_TOPICS"><A HREF="#ADVANCED_TOPICS">ADVANCED TOPICS</A></A>
<UL>
<LI> <A NAME="menu:Auto-formatting_and_inserting_newlines"><A HREF="#Auto-formatting_and_inserting_newlines">Auto-formatting and inserting newlines</A></A>
<LI> <A NAME="menu:Entities"><A HREF="#Entities">Entities</A></A>
<LI> <A NAME="menu:Auto-escaping_changing_the_way_text_is_escaped"><A HREF="#Auto-escaping_changing_the_way_text_is_escaped">Auto-escaping: changing the way text is escaped</A></A>
<LI> <A NAME="menu:Outputting_HTML_to_things_besides_filehandles"><A HREF="#Outputting_HTML_to_things_besides_filehandles">Outputting HTML to things besides filehandles</A></A>
<LI> <A NAME="menu:Subclassing"><A HREF="#Subclassing">Subclassing</A></A>
</UL>
<LI> <A NAME="menu:PUBLIC_INTERFACE"><A HREF="#PUBLIC_INTERFACE">PUBLIC INTERFACE</A></A>
<UL>
<LI> <A NAME="menu:Functions"><A HREF="#Functions">Functions</A></A>
<UL>
<LI> <A NAME="menu:item:html_escape_TEXT"><A HREF="#item:html_escape_TEXT">html_escape TEXT</A></A>
<LI> <A NAME="menu:item:html_tag_TAG_PARAM_VALUE"><A HREF="#item:html_tag_TAG_PARAM_VALUE">html_tag TAG [, PARAM=&gt;VALUE, ...]</A></A>
<LI> <A NAME="menu:item:html_unescape_TEXT"><A HREF="#item:html_unescape_TEXT">html_unescape TEXT</A></A>
<LI> <A NAME="menu:item:html_unmarkup_TEXT"><A HREF="#item:html_unmarkup_TEXT">html_unmarkup TEXT</A></A>
</UL>
<LI> <A NAME="menu:Vanilla"><A HREF="#Vanilla">Vanilla</A></A>
<UL>
<LI> <A NAME="menu:item:new_PRINTABLE"><A HREF="#item:new_PRINTABLE">new [PRINTABLE] </A></A>
<LI> <A NAME="menu:item:auto_escape_NAME_SUBREF"><A HREF="#item:auto_escape_NAME_SUBREF">auto_escape [NAME|SUBREF]</A></A>
<LI> <A NAME="menu:item:auto_format_ONOFF"><A HREF="#item:auto_format_ONOFF">auto_format ONOFF</A></A>
<LI> <A NAME="menu:item:comment_COMMENT"><A HREF="#item:comment_COMMENT">comment COMMENT</A></A>
<LI> <A NAME="menu:item:ent_ENTITY"><A HREF="#item:ent_ENTITY">ent ENTITY</A></A>
<LI> <A NAME="menu:item:io"><A HREF="#item:io">io</A></A>
<LI> <A NAME="menu:item:nl_COUNT"><A HREF="#item:nl_COUNT">nl [COUNT]</A></A>
<LI> <A NAME="menu:item:tag_TAGNAME_PARAM_VALUE"><A HREF="#item:tag_TAGNAME_PARAM_VALUE">tag TAGNAME [, PARAM=&gt;VALUE, ...]</A></A>
<LI> <A NAME="menu:item:text_TEXT"><A HREF="#item:text_TEXT">text TEXT...</A></A>
<LI> <A NAME="menu:item:text_nbsp_TEXT"><A HREF="#item:text_nbsp_TEXT">text_nbsp TEXT...</A></A>
</UL>
<LI> <A NAME="menu:Strawberry"><A HREF="#Strawberry">Strawberry</A></A>
<UL>
<LI> <A NAME="menu:item:output_ITEM_ITEM"><A HREF="#item:output_ITEM_ITEM">output ITEM,...,ITEM</A></A>
</UL>
<LI> <A NAME="menu:Chocolate"><A HREF="#Chocolate">Chocolate</A></A>
<UL>
<LI> <A NAME="menu:item:accept_tag_TAG"><A HREF="#item:accept_tag_TAG">accept_tag TAG</A></A>
<LI> <A NAME="menu:item:private_tags"><A HREF="#item:private_tags">private_tags </A></A>
<LI> <A NAME="menu:item:set_tag_TAG_TAGINFO"><A HREF="#item:set_tag_TAG_TAGINFO">set_tag TAG, [TAGINFO...]</A></A>
<LI> <A NAME="menu:item:tags"><A HREF="#item:tags">tags </A></A>
</UL>
</UL>
<LI> <A NAME="menu:SUBCLASSES"><A HREF="#SUBCLASSES">SUBCLASSES</A></A>
<UL>
<LI> <A NAME="menu:HTML_Stream_Latin1"><A HREF="#HTML_Stream_Latin1">HTML::Stream::Latin1</A></A>
</UL>
<LI> <A NAME="menu:PERFORMANCE"><A HREF="#PERFORMANCE">PERFORMANCE</A></A>
<LI> <A NAME="menu:VERSION"><A HREF="#VERSION">VERSION</A></A>
<LI> <A NAME="menu:CHANGE_LOG"><A HREF="#CHANGE_LOG">CHANGE LOG</A></A>
<UL>
<LI> <A NAME="menu:item:Version_1_54_2001_08_20"><A HREF="#item:Version_1_54_2001_08_20">Version 1.54   (2001/08/20)</A></A>
<LI> <A NAME="menu:item:Version_1_51_2001_08_16"><A HREF="#item:Version_1_51_2001_08_16">Version 1.51   (2001/08/16)</A></A>
<LI> <A NAME="menu:item:Version_1_47_2000_06_10"><A HREF="#item:Version_1_47_2000_06_10">Version 1.47   (2000/06/10)</A></A>
<LI> <A NAME="menu:item:Version_1_45_1999_02_09"><A HREF="#item:Version_1_45_1999_02_09">Version 1.45   (1999/02/09)</A></A>
<LI> <A NAME="menu:item:Version_1_44_1998_01_14"><A HREF="#item:Version_1_44_1998_01_14">Version 1.44   (1998/01/14)</A></A>
<LI> <A NAME="menu:item:Version_1_41_1998_01_02"><A HREF="#item:Version_1_41_1998_01_02">Version 1.41   (1998/01/02)</A></A>
<LI> <A NAME="menu:item:Version_1_37_1997_02_09"><A HREF="#item:Version_1_37_1997_02_09">Version 1.37   (1997/02/09)</A></A>
<LI> <A NAME="menu:item:Version_1_32_1997_01_12"><A HREF="#item:Version_1_32_1997_01_12">Version 1.32   (1997/01/12)</A></A>
<LI> <A NAME="menu:item:Version_1_29_1996_12_10"><A HREF="#item:Version_1_29_1996_12_10">Version 1.29   (1996/12/10)</A></A>
<LI> <A NAME="menu:item:Version_1_27_1996_12_10"><A HREF="#item:Version_1_27_1996_12_10">Version 1.27   (1996/12/10)</A></A>
<LI> <A NAME="menu:item:Version_1_26_1996_09_27"><A HREF="#item:Version_1_26_1996_09_27">Version 1.26   (1996/09/27)</A></A>
</UL>
<LI> <A NAME="menu:ACKNOWLEDGEMENTS"><A HREF="#ACKNOWLEDGEMENTS">ACKNOWLEDGEMENTS</A></A>
<LI> <A NAME="menu:AUTHOR"><A HREF="#AUTHOR">AUTHOR</A></A>
</UL>


<P><HR>
<A NAME="NAME"><H2><A HREF="#__TOP__"><IMG SRC="icons/h1bullet.gif" ALT="Top" BORDER="0"></A> NAME</H2></A>


<P>HTML::Stream - HTML output stream class, and some markup utilities



<P><HR>
<A NAME="SYNOPSIS"><H2><A HREF="#__TOP__"><IMG SRC="icons/h1bullet.gif" ALT="Top" BORDER="0"></A> SYNOPSIS</H2></A>


<P>Here's small sample of some of the non-OO ways you can use this module:

<FONT SIZE=3 FACE="courier"><PRE>
      use HTML::Stream qw(:funcs);
      
      print html_tag('A', HREF=&gt;$link);     
      print html_escape(&quot;&lt;&lt;Hello &amp; welcome!&gt;&gt;&quot;);      
</PRE></FONT>

<P>And some of the OO ways as well:

<FONT SIZE=3 FACE="courier"><PRE>
      use HTML::Stream;
      $HTML = new HTML::Stream \*STDOUT;
      
      # The vanilla interface...
      $HTML-&gt;tag('A', HREF=&gt;&quot;$href&quot;);
      $HTML-&gt;tag('IMG', SRC=&gt;&quot;logo.gif&quot;, ALT=&gt;&quot;LOGO&quot;);
      $HTML-&gt;text($copyright);
      $HTML-&gt;tag('_A');
      
      # The chocolate interface...
      $HTML -&gt; A(HREF=&gt;&quot;$href&quot;);
      $HTML -&gt; IMG(SRC=&gt;&quot;logo.gif&quot;, ALT=&gt;&quot;LOGO&quot;);
      $HTML -&gt; t($caption);
      $HTML -&gt; _A;
       
      # The chocolate interface, with whipped cream...
      $HTML -&gt; A(HREF=&gt;&quot;$href&quot;)
            -&gt; IMG(SRC=&gt;&quot;logo.gif&quot;, ALT=&gt;&quot;LOGO&quot;)
            -&gt; t($caption)
            -&gt; _A;
</PRE></FONT>
<FONT SIZE=3 FACE="courier"><PRE>
      # The strawberry interface...
      output $HTML [A, HREF=&gt;&quot;$href&quot;], 
                   [IMG, SRC=&gt;&quot;logo.gif&quot;, ALT=&gt;&quot;LOGO&quot;],
                   $caption,
                   [_A];
</PRE></FONT>


<P><HR>
<A NAME="DESCRIPTION"><H2><A HREF="#__TOP__"><IMG SRC="icons/h1bullet.gif" ALT="Top" BORDER="0"></A> DESCRIPTION</H2></A>


<P>The <B>HTML::Stream</B> module provides you with an object-oriented
(and subclassable) way of outputting HTML.  Basically, you open up 
an &quot;HTML stream&quot; on an existing filehandle, and then do all of your  
output to the HTML stream.  You can intermix HTML-stream-output and 
ordinary-print-output, if you like.


<P>There's even a small built-in subclass, <B>HTML::Stream::Latin1</B>, which can
handle Latin-1 input right out of the box.   But all in good time...



<P><HR>
<A NAME="INTRODUCTION_the_Neapolitan_dessert_special"><H2><A HREF="#__TOP__"><IMG SRC="icons/h1bullet.gif" ALT="Top" BORDER="0"></A> INTRODUCTION (the Neapolitan dessert special)</H2></A>



<P><HR>
<A NAME="Function_interface"><H3><A HREF="#__TOP__"><IMG SRC="icons/h2bullet.gif" ALT="Top" BORDER="0"></A> Function interface</H3></A>


<P>Let's start out with the simple stuff.
This module provides a collection of non-OO utility functions
for escaping HTML text and producing HTML tags, like this:

<FONT SIZE=3 FACE="courier"><PRE>
    use HTML::Stream qw(:funcs);        # imports functions from @EXPORT_OK
    
    print html_tag(A, HREF=&gt;$url);
    print '&amp;copy; 1996 by', html_escape($myname), '!';
    print html_tag('/A');
</PRE></FONT>

<P>By the way: that last line could be rewritten as:

<FONT SIZE=3 FACE="courier"><PRE>
    print html_tag(_A);
</PRE></FONT>

<P>And if you need to get a parameter in your tag that doesn't have an
associated value, supply the <I>undefined</I> value (<I>not</I> the empty string!):

<FONT SIZE=3 FACE="courier"><PRE>
    print html_tag(TD, NOWRAP=&gt;undef, ALIGN=&gt;'LEFT');
    
         &lt;TD NOWRAP ALIGN=LEFT&gt;
    
    print html_tag(IMG, SRC=&gt;'logo.gif', ALT=&gt;'');
    
         &lt;IMG SRC=&quot;logo.gif&quot; ALT=&quot;&quot;&gt;
</PRE></FONT>

<P>There are also some routines for reversing the process, like:

<FONT SIZE=3 FACE="courier"><PRE>
    $text = &quot;This &lt;i&gt;isn't&lt;/i&gt; &amp;quot;fun&amp;quot;...&quot;;    
    print html_unmarkup($text);
       
         This isn't &amp;quot;fun&amp;quot;...
      
    print html_unescape($text);
       
         This isn't &quot;fun&quot;...
</PRE></FONT>

<P><I>Yeah, yeah, yeah</I>, I hear you cry.  <I>We've seen this stuff before.</I>
But wait!  There's more...



<P><HR>
<A NAME="OO_interface_vanilla"><H3><A HREF="#__TOP__"><IMG SRC="icons/h2bullet.gif" ALT="Top" BORDER="0"></A> OO interface, vanilla</H3></A>


<P>Using the function interface can be tedious... so we also
provide an <B>&quot;HTML output stream&quot;</B> class.  Messages to an instance of
that class generally tell that stream to output some HTML.  Here's the
above example, rewritten using HTML streams:

<FONT SIZE=3 FACE="courier"><PRE>
    use HTML::Stream;
    $HTML = new HTML::Stream \*STDOUT;
    
    $HTML-&gt;tag(A, HREF=&gt;$url);
    $HTML-&gt;ent('copy');
    $HTML-&gt;text(&quot; 1996 by $myname!&quot;);
    $HTML-&gt;tag(_A);
</PRE></FONT>

<P>As you've probably guessed:

<FONT SIZE=3 FACE="courier"><PRE>
    text()   Outputs some text, which will be HTML-escaped.
    
    tag()    Outputs an ordinary tag, like &lt;A&gt;, possibly with parameters.
             The parameters will all be HTML-escaped automatically.
     
    ent()    Outputs an HTML entity, like the &amp;copy; or &amp;lt; .
             You mostly don't need to use it; you can often just put the 
             Latin-1 representation of the character in the text().
</PRE></FONT>

<P>You might prefer to use <CODE>t()</CODE> and <CODE>e()</CODE> instead of <CODE>text()</CODE> 
and <CODE>ent()</CODE>: they're absolutely identical, and easier to type:

<FONT SIZE=3 FACE="courier"><PRE>
    $HTML -&gt; tag(A, HREF=&gt;$url);
    $HTML -&gt; e('copy');
    $HTML -&gt; t(&quot; 1996 by $myname!&quot;);
    $HTML -&gt; tag(_A);
</PRE></FONT>

<P>Now, it wouldn't be nice to give you those <CODE>text()</CODE> and <CODE>ent()</CODE> shortcuts
without giving you one for <CODE>tag()</CODE>, would it?  Of course not...



<P><HR>
<A NAME="OO_interface_chocolate"><H3><A HREF="#__TOP__"><IMG SRC="icons/h2bullet.gif" ALT="Top" BORDER="0"></A> OO interface, chocolate</H3></A>


<P>The known HTML tags are even given their own <B>tag-methods,</B> compiled on 
demand.  The above code could be written even more compactly as:

<FONT SIZE=3 FACE="courier"><PRE>
    $HTML -&gt; A(HREF=&gt;$url);
    $HTML -&gt; e('copy');
    $HTML -&gt; t(&quot; 1996 by $myname!&quot;);
    $HTML -&gt; _A;
</PRE></FONT>

<P>As you've probably guessed:

<FONT SIZE=3 FACE="courier"><PRE>
    A(HREF=&gt;$url)   ==   tag(A, HREF=&gt;$url)   ==   &lt;A HREF=&quot;/the/url&quot;&gt;
    _A              ==   tag(_A)              ==   &lt;/A&gt;
</PRE></FONT>

<P>All of the autoloaded &quot;tag-methods&quot; use the tagname in <I>all-uppercase</I>.
A <CODE>&quot;_&quot;</CODE> prefix on any tag-method means that an end-tag is desired.
The <CODE>&quot;_&quot;</CODE> was chosen for several reasons: 
(1) it's short and easy to type,
(2) it doesn't produce much visual clutter to look at,
(3) <CODE>_TAG</CODE> looks a little like <CODE>/TAG</CODE> because of the straight line.



<UL>
<P><LI>
<P><I>I know, I know... it looks like a private method.
You get used to it.  Really.</I>

</UL>


<P>I should stress that this module will only auto-create tag methods
for <B>known</B> HTML tags.  So you're protected from typos like this
(which will cause a fatal exception at run-time):

<FONT SIZE=3 FACE="courier"><PRE>
    $HTML -&gt; IMGG(SRC=&gt;$src);
</PRE></FONT>

<P>(You're not yet protected from illegal tag parameters, but it's a start, 
ain't it?)


<P>If you need to make a tag known (sorry, but this is currently a 
<I>global</I> operation, and not stream-specific), do this:

<FONT SIZE=3 FACE="courier"><PRE>
    accept_tag HTML::Stream 'MARQUEE';       # for you MSIE fans...
</PRE></FONT>

<P><B>Note: there is no corresponding &quot;reject_tag&quot;.</B>  I thought and thought
about it, and could not convince myself that such a method would 
do anything more useful than cause other people's modules to suddenly
stop working because some bozo function decided to reject the <CODE>FONT</CODE> tag.



<P><HR>
<A NAME="OO_interface_with_whipped_cream"><H3><A HREF="#__TOP__"><IMG SRC="icons/h2bullet.gif" ALT="Top" BORDER="0"></A> OO interface, with whipped cream</H3></A>


<P>In the grand tradition of C++, output method chaining is supported
in both the Vanilla Interface and the Chocolate Interface.  
So you can (and probably should) write the above code as:

<FONT SIZE=3 FACE="courier"><PRE>
    $HTML -&gt; A(HREF=&gt;$url) 
          -&gt; e('copy') -&gt; t(&quot; 1996 by $myname!&quot;) 
          -&gt; _A;
</PRE></FONT>

<P><I>But wait!  Neapolitan ice cream has one more flavor...</I>



<P><HR>
<A NAME="OO_interface_strawberry"><H3><A HREF="#__TOP__"><IMG SRC="icons/h2bullet.gif" ALT="Top" BORDER="0"></A> OO interface, strawberry</H3></A>


<P>I was jealous of the compact syntax of HTML::AsSubs, but I didn't
want to worry about clogging the namespace with a lot of functions
like p(), a(), etc. (especially when markup-functions like tr() conflict
with existing Perl functions).  So I came up with this:

<FONT SIZE=3 FACE="courier"><PRE>
    output $HTML [A, HREF=&gt;$url], &quot;Here's my $caption&quot;, [_A];
</PRE></FONT>

<P>Conceptually, arrayrefs are sent to <CODE>html_tag()</CODE>, and strings to 
<CODE>html_escape()</CODE>.



<P><HR>
<A NAME="ADVANCED_TOPICS"><H2><A HREF="#__TOP__"><IMG SRC="icons/h1bullet.gif" ALT="Top" BORDER="0"></A> ADVANCED TOPICS</H2></A>



<P><HR>
<A NAME="Auto-formatting_and_inserting_newlines"><H3><A HREF="#__TOP__"><IMG SRC="icons/h2bullet.gif" ALT="Top" BORDER="0"></A> Auto-formatting and inserting newlines</H3></A>


<P><I>Auto-formatting</I> is the name I give to the Chocolate Interface feature
whereby newlines (and maybe, in the future, other things)
are inserted before or after the tags you output in order to make 
your HTML more readable.  So, by default, this:

<FONT SIZE=3 FACE="courier"><PRE>
    $HTML -&gt; HTML 
          -&gt; HEAD  
          -&gt; TITLE -&gt; t(&quot;Hello!&quot;) -&gt; _TITLE 
          -&gt; _HEAD
          -&gt; BODY(BGCOLOR=&gt;'#808080');
</PRE></FONT>

<P>Actually produces this:

<FONT SIZE=3 FACE="courier"><PRE>
    &lt;HTML&gt;&lt;HTML&gt;
    &lt;HEAD&gt;
    &lt;TITLE&gt;Hello!&lt;/TITLE&gt;
    &lt;/HEAD&gt;
    &lt;BODY BGCOLOR=&quot;#808080&quot;&gt;
</PRE></FONT>

<P><B>To turn off autoformatting altogether</B> on a given HTML::Stream object,
use the <CODE>auto_format()</CODE> method:

<FONT SIZE=3 FACE="courier"><PRE>
    $HTML-&gt;auto_format(0);        # stop autoformatting!
</PRE></FONT>

<P><B>To change whether a newline is automatically output</B> before/after the 
begin/end form of a tag at a <B>global</B> level, use <CODE>set_tag()</CODE>:

<FONT SIZE=3 FACE="courier"><PRE>
    HTML::Stream-&gt;set_tag('B', Newlines=&gt;15);   # 15 means &quot;\n&lt;B&gt;\n \n&lt;/B&gt;\n&quot;
    HTML::Stream-&gt;set_tag('I', Newlines=&gt;7);    # 7 means  &quot;\n&lt;I&gt;\n \n&lt;/I&gt;  &quot;
</PRE></FONT>

<P><B>To change whether a newline is automatically output</B> before/after the 
begin/end form of a tag <B>for a given stream</B> level, give the stream
its own private &quot;tag info&quot; table, and then use <CODE>set_tag()</CODE>:

<FONT SIZE=3 FACE="courier"><PRE>
    $HTML-&gt;private_tags;
    $HTML-&gt;set_tag('B', Newlines=&gt;0);     # won't affect anyone else!
</PRE></FONT>

<P><B>To output newlines explicitly</B>, just use the special <CODE>nl</CODE> method
in the Chocolate Interface:

<FONT SIZE=3 FACE="courier"><PRE>
    $HTML-&gt;nl;     # one newline
    $HTML-&gt;nl(6);  # six newlines
</PRE></FONT>

<P>I am sometimes asked, &quot;why don't you put more newlines in automatically?&quot;
Well, mostly because...



<UL>
<P><LI>
<P>Sometimes you'll be outputting stuff inside a <CODE>PRE</CODE> environment.

<P><LI>
<P>Sometimes you really do want to jam things (like images, or table
cell delimiters and the things they contain) right up against each other.

</UL>


<P>So I've stuck to outputting newlines in places where it's most likely
to be harmless. 



<P><HR>
<A NAME="Entities"><H3><A HREF="#__TOP__"><IMG SRC="icons/h2bullet.gif" ALT="Top" BORDER="0"></A> Entities</H3></A>


<P>As shown above, You can use the <CODE>ent()</CODE> (or <CODE>e()</CODE>) method to output 
an entity:

<FONT SIZE=3 FACE="courier"><PRE>
    $HTML-&gt;t('Copyright ')-&gt;e('copy')-&gt;t(' 1996 by Me!');
</PRE></FONT>

<P>But this can be a pain, particularly for generating output with
non-ASCII characters:

<FONT SIZE=3 FACE="courier"><PRE>
    $HTML -&gt; t('Copyright ') 
          -&gt; e('copy') 
          -&gt; t(' 1996 by Fran') -&gt; e('ccedil') -&gt; t('ois, Inc.!');
</PRE></FONT>

<P>Granted, Europeans can always type the 8-bit characters directly in
their Perl code, and just have this:

<FONT SIZE=3 FACE="courier"><PRE>
    $HTML -&gt; t(&quot;Copyright \251 1996 by Fran\347ois, Inc.!');
</PRE></FONT>

<P>But folks without 8-bit text editors can find this kind of output
cumbersome to generate.  Sooooooooo...



<P><HR>
<A NAME="Auto-escaping_changing_the_way_text_is_escaped"><H3><A HREF="#__TOP__"><IMG SRC="icons/h2bullet.gif" ALT="Top" BORDER="0"></A> Auto-escaping: changing the way text is escaped</H3></A>


<P><I>Auto-escaping</I> is the name I give to the act of taking an &quot;unsafe&quot;
string (one with &quot;&gt;&quot;, &quot;&amp;&quot;, etc.), and magically outputting &quot;safe&quot; HTML.


<P>The default &quot;auto-escape&quot; behavior of an HTML stream can be a drag if
you've got a lot character entities that you want to output, or if 
you're using the Latin-1 character set, or some other input encoding.  
Fortunately, you can use the <CODE>auto_escape()</CODE> method to change the 
way a particular HTML::Stream works at any time.


<P>First, here's a couple of special invocations:

<FONT SIZE=3 FACE="courier"><PRE>
    $HTML-&gt;auto_escape('ALL');      # Default; escapes [&lt;&gt;&quot;&amp;] and 8-bit chars.
    $HTML-&gt;auto_escape('LATIN_1');  # Like ALL, but uses Latin-1 entities
                                    #   instead of decimal equivalents.
    $HTML-&gt;auto_escape('NON_ENT');  # Like ALL, but leaves &quot;&amp;&quot; alone.
</PRE></FONT>

<P>You can also install your own auto-escape function (note
that you might very well want to install it for just a little bit
only, and then de-install it):

<FONT SIZE=3 FACE="courier"><PRE>
    sub my_auto_escape {
        my $text = shift;
	HTML::Entities::encode($text);     # start with default
        $text =~ s/\(c\)/&amp;copy;/ig;        # (C) becomes copyright
        $text =~ s/\\,(c)/\&amp;$1cedil;/ig;   # \,c becomes a cedilla
 	$text;
    }
    
    # Start using my auto-escape:
    my $old_esc = $HTML-&gt;auto_escape(\&amp;my_auto_escape);  
    
    # Output some stuff:
    $HTML-&gt; IMG(SRC=&gt;'logo.gif', ALT=&gt;'Fran\,cois, Inc');
    output $HTML 'Copyright (C) 1996 by Fran\,cois, Inc.!';
    
    # Stop using my auto-escape:
    $HTML-&gt;auto_escape($old_esc);
</PRE></FONT>

<P>If you find yourself in a situation where you're doing this a lot,
a better way is to create a <B>subclass</B> of HTML::Stream which installs
your custom function when constructed.  For an example, see the 
<B>HTML::Stream::Latin1</B> subclass in this module.



<P><HR>
<A NAME="Outputting_HTML_to_things_besides_filehandles"><H3><A HREF="#__TOP__"><IMG SRC="icons/h2bullet.gif" ALT="Top" BORDER="0"></A> Outputting HTML to things besides filehandles</H3></A>


<P>As of Revision 1.21, you no longer need to supply <CODE>new()</CODE> with a 
filehandle: <I>any object that responds to a print() method will do</I>.
Of course, this includes <B>blessed</B> FileHandles, and IO::Handles.


<P>If you supply a GLOB reference (like <CODE>\*STDOUT</CODE>) or a string (like
<CODE>&quot;Module::FH&quot;</CODE>), HTML::Stream will automatically create an invisible
object for talking to that filehandle (I don't dare bless it into a
FileHandle, since the underlying descriptor would get closed when 
the HTML::Stream is destroyed, and you might not want that).


<P>You say you want to print to a string?  For kicks and giggles, try this:

<FONT SIZE=3 FACE="courier"><PRE>
    package StringHandle;
    sub new {
	my $self = '';
	bless \$self, shift;
    }
    sub print {
        my $self = shift;
        $$self .= join('', @_);
    }
    
  
    package main;
    use HTML::Stream;
    
    my $SH = new StringHandle;
    my $HTML = new HTML::Stream $SH;
    $HTML -&gt; H1 -&gt; t(&quot;Hello &amp; &lt;&lt;welcome&gt;&gt;!&quot;) -&gt; _H1;
    print &quot;PRINTED STRING: &quot;, $$SH, &quot;\n&quot;;
</PRE></FONT>


<P><HR>
<A NAME="Subclassing"><H3><A HREF="#__TOP__"><IMG SRC="icons/h2bullet.gif" ALT="Top" BORDER="0"></A> Subclassing</H3></A>


<P>This is where you can make your application-specific HTML-generating code
<I>much</I> easier to look at.  Consider this:

<FONT SIZE=3 FACE="courier"><PRE>
    package MY::HTML;
    @ISA = qw(HTML::Stream);
     
    sub Aside {
	$_[0] -&gt; FONT(SIZE=&gt;-1) -&gt; I;
    }
    sub _Aside {
	$_[0] -&gt; _I -&gt; _FONT;
    }
</PRE></FONT>

<P>Now, you can do this:

<FONT SIZE=3 FACE="courier"><PRE>
    my $HTML = new MY::HTML \*STDOUT;
    
    $HTML -&gt; Aside
          -&gt; t(&quot;Don't drink the milk, it's spoiled... pass it on...&quot;)
          -&gt; _Aside;
</PRE></FONT>

<P>If you're defining these markup-like, chocolate-interface-style functions,
I recommend using mixed case with a leading capital.  You probably 
shouldn't use all-uppercase, since that's what this module uses for
real HTML tags.



<P><HR>
<A NAME="PUBLIC_INTERFACE"><H2><A HREF="#__TOP__"><IMG SRC="icons/h1bullet.gif" ALT="Top" BORDER="0"></A> PUBLIC INTERFACE</H2></A>



<P><HR>
<A NAME="Functions"><H3><A HREF="#__TOP__"><IMG SRC="icons/h2bullet.gif" ALT="Top" BORDER="0"></A> Functions</H3></A>



<DL>
<P><DT><B><A HREF="#__TOP__"><IMG SRC="icons/itembullet.gif" ALT="Top" BORDER="0"></A> <A NAME="item:html_escape"><A NAME="item:html_escape_TEXT">html_escape TEXT</A></A></B></DT>
<DD>
Given a TEXT string, turn the text into valid HTML by escaping &quot;unsafe&quot; 
characters.  Currently, the &quot;unsafe&quot; characters are 8-bit characters plus:

<FONT SIZE=3 FACE="courier"><PRE>
    &lt;  &gt;  =  &amp;
</PRE></FONT>

<P><B>Note:</B> provided for convenience and backwards-compatibility only.
You may want to use the more-powerful <B>HTML::Entities::encode</B>
function instead.

<P><DT><B><A HREF="#__TOP__"><IMG SRC="icons/itembullet.gif" ALT="Top" BORDER="0"></A> <A NAME="item:html_tag"><A NAME="item:html_tag_TAG_PARAM_VALUE">html_tag TAG [, PARAM=&gt;VALUE, ...]</A></A></B></DT>
<DD>
Return the text for a given TAG, possibly with parameters.
As an efficiency hack, only the values are HTML-escaped currently:
it is assumed that the tag and parameters will already be safe.


<P>For convenience and readability, you can say <CODE>_A</CODE> instead of <CODE>&quot;/A&quot;</CODE>
for the first tag, if you're into barewords.

<P><DT><B><A HREF="#__TOP__"><IMG SRC="icons/itembullet.gif" ALT="Top" BORDER="0"></A> <A NAME="item:html_unescape"><A NAME="item:html_unescape_TEXT">html_unescape TEXT</A></A></B></DT>
<DD>
Remove angle-tag markup, and convert the standard ampersand-escapes
(<CODE>lt</CODE>, <CODE>gt</CODE>, <CODE>amp</CODE>, <CODE>quot</CODE>, and <CODE>#ddd</CODE>) into ASCII characters.


<P><B>Note:</B> provided for convenience and backwards-compatibility only.
You may want to use the more-powerful <B>HTML::Entities::decode</B>
function instead: unlike this function, it can collapse entities
like <CODE>copy</CODE> and <CODE>ccedil</CODE> into their Latin-1 byte values.

<P><DT><B><A HREF="#__TOP__"><IMG SRC="icons/itembullet.gif" ALT="Top" BORDER="0"></A> <A NAME="item:html_unmarkup"><A NAME="item:html_unmarkup_TEXT">html_unmarkup TEXT</A></A></B></DT>
<DD>
Remove angle-tag markup from TEXT, but do not convert ampersand-escapes.  
Cheesy, but theoretically useful if you want to, say, incorporate
externally-provided HTML into a page you're generating, and are worried
that the HTML might contain undesirable markup.

</DL>



<P><HR>
<A NAME="Vanilla"><H3><A HREF="#__TOP__"><IMG SRC="icons/h2bullet.gif" ALT="Top" BORDER="0"></A> Vanilla</H3></A>



<DL>
<P><DT><B><A HREF="#__TOP__"><IMG SRC="icons/itembullet.gif" ALT="Top" BORDER="0"></A> <A NAME="item:new"><A NAME="item:new_PRINTABLE">new [PRINTABLE]</A></A></B></DT>
<DD>
<I>Class method.</I>
Create a new HTML output stream.


<P>The PRINTABLE may be a FileHandle, a glob reference, or any object
that responds to a <CODE>print()</CODE> message.
If no PRINTABLE is given, does a select() and uses that.

<P><DT><B><A HREF="#__TOP__"><IMG SRC="icons/itembullet.gif" ALT="Top" BORDER="0"></A> <A NAME="item:auto_escape"><A NAME="item:auto_escape_NAME_SUBREF">auto_escape [NAME|SUBREF]</A></A></B></DT>
<DD>
<I>Instance method.</I>
Set the auto-escape function for this HTML stream.


<P>If the argument is a subroutine reference SUBREF, then that subroutine 
will be used.  Declare such subroutines like this:

<FONT SIZE=3 FACE="courier"><PRE>
    sub my_escape {
	my $text = shift;     # it's passed in the first argument
        ...
        $text;
    }
</PRE></FONT>

<P>If a textual NAME is given, then one of the appropriate built-in 
functions is used.  Possible values are:



<DL>
<P><DT><B><A NAME="item:ALL">ALL</A></B></DT>
<DD>
Default for HTML::Stream objects.  This escapes angle brackets, 
ampersands, double-quotes, and 8-bit characters.  8-bit characters 
are escaped using decimal entity codes (like <CODE>#123</CODE>).

<P><DT><B><A NAME="item:LATIN_1">LATIN_1</A></B></DT>
<DD>
Like <CODE>&quot;ALL&quot;</CODE>, but uses Latin-1 entity names (like <CODE>ccedil</CODE>) instead of
decimal entity codes to escape characters.  This makes the HTML more readable
but it is currently not advised, as &quot;older&quot; browsers (like Netscape 2.0)
do not recognize many of the ISO-8859-1 entity names (like <CODE>deg</CODE>).


<P><B>Warning:</B> If you specify this option, you'll find that it attempts
to &quot;require&quot; <B>HTML::Entities</B> at run time.  That's because I didn't want 
to <I>force</I> you to have that module just to use the rest of HTML::Stream.
To pick up problems at compile time, you are advised to say:

<FONT SIZE=3 FACE="courier"><PRE>
    use HTML::Stream;
    use HTML::Entities;
</PRE></FONT>

<P>in your source code.

<P><DT><B><A NAME="item:NON_ENT">NON_ENT</A></B></DT>
<DD>
Like <CODE>&quot;ALL&quot;</CODE>, except that ampersands (&amp;) are <I>not</I> escaped.
This allows you to use &amp;-entities in your text strings, while having
everything else safely escaped:

<FONT SIZE=3 FACE="courier"><PRE>
    output $HTML &quot;If A is an acute angle, then A &gt; 90&amp;deg;&quot;;
</PRE></FONT>
</DL>


<P>Returns the previously-installed function, in the manner of <CODE>select()</CODE>.
No arguments just returns the currently-installed function.

<P><DT><B><A HREF="#__TOP__"><IMG SRC="icons/itembullet.gif" ALT="Top" BORDER="0"></A> <A NAME="item:auto_format"><A NAME="item:auto_format_ONOFF">auto_format ONOFF</A></A></B></DT>
<DD>
<I>Instance method.</I>
Set the auto-formatting characteristics for this HTML stream.
Currently, all you can do is supply a single defined boolean
argument, which turns auto-formatting ON (1) or OFF (0). 
The self object is returned.


<P>Please use no other values; they are reserved for future use.

<P><DT><B><A HREF="#__TOP__"><IMG SRC="icons/itembullet.gif" ALT="Top" BORDER="0"></A> <A NAME="item:comment"><A NAME="item:comment_COMMENT">comment COMMENT</A></A></B></DT>
<DD>
<I>Instance method.</I>
Output an HTML comment.
As of 1.29, a newline is automatically appended.

<P><DT><B><A HREF="#__TOP__"><IMG SRC="icons/itembullet.gif" ALT="Top" BORDER="0"></A> <A NAME="item:ent"><A NAME="item:ent_ENTITY">ent ENTITY</A></A></B></DT>
<DD>
<I>Instance method.</I>
Output an HTML entity.  For example, here's how you'd output a 
non-breaking space:

<FONT SIZE=3 FACE="courier"><PRE>
      $html-&gt;ent('nbsp');
</PRE></FONT>

<P>You may abbreviate this method name as <CODE>e</CODE>:

<FONT SIZE=3 FACE="courier"><PRE>
      $html-&gt;e('nbsp');
</PRE></FONT>

<P><B>Warning:</B> this function assumes that the entity argument is legal.

<P><DT><B><A HREF="#__TOP__"><IMG SRC="icons/itembullet.gif" ALT="Top" BORDER="0"></A> <A NAME="item:io">io</A></B></DT>
<DD>
Return the underlying output handle for this HTML stream.
All you can depend upon is that it is some kind of object
which responds to a print() message:

<FONT SIZE=3 FACE="courier"><PRE>
    $HTML-&gt;io-&gt;print(&quot;This is not auto-escaped or nuthin!&quot;);
</PRE></FONT>
<P><DT><B><A HREF="#__TOP__"><IMG SRC="icons/itembullet.gif" ALT="Top" BORDER="0"></A> <A NAME="item:nl"><A NAME="item:nl_COUNT">nl [COUNT]</A></A></B></DT>
<DD>
<I>Instance method.</I>
Output COUNT newlines.  If undefined, COUNT defaults to 1.

<P><DT><B><A HREF="#__TOP__"><IMG SRC="icons/itembullet.gif" ALT="Top" BORDER="0"></A> <A NAME="item:tag"><A NAME="item:tag_TAGNAME_PARAM_VALUE">tag TAGNAME [, PARAM=&gt;VALUE, ...]</A></A></B></DT>
<DD>
<I>Instance method.</I>
Output a tag.  Returns the self object, to allow method chaining.
You can say <CODE>_A</CODE> instead of <CODE>&quot;/A&quot;</CODE>, if you're into barewords.

<P><DT><B><A HREF="#__TOP__"><IMG SRC="icons/itembullet.gif" ALT="Top" BORDER="0"></A> <A NAME="item:text"><A NAME="item:text_TEXT">text TEXT...</A></A></B></DT>
<DD>
<I>Instance method.</I>
Output some text.  You may abbreviate this method name as <CODE>t</CODE>:

<FONT SIZE=3 FACE="courier"><PRE>
      $html-&gt;t('Hi there, ', $yournamehere, '!');
</PRE></FONT>

<P>Returns the self object, to allow method chaining.

<P><DT><B><A HREF="#__TOP__"><IMG SRC="icons/itembullet.gif" ALT="Top" BORDER="0"></A> <A NAME="item:text_nbsp"><A NAME="item:text_nbsp_TEXT">text_nbsp TEXT...</A></A></B></DT>
<DD>
<I>Instance method.</I>
Output some text, but with all spaces output as non-breaking-space
characters: 

<FONT SIZE=3 FACE="courier"><PRE>
      $html-&gt;t(&quot;To list your home directory, type: &quot;)
           -&gt;text_nbsp(&quot;ls -l ~yourname.&quot;)
</PRE></FONT>

<P>Returns the self object, to allow method chaining.

</DL>



<P><HR>
<A NAME="Strawberry"><H3><A HREF="#__TOP__"><IMG SRC="icons/h2bullet.gif" ALT="Top" BORDER="0"></A> Strawberry</H3></A>



<DL>
<P><DT><B><A HREF="#__TOP__"><IMG SRC="icons/itembullet.gif" ALT="Top" BORDER="0"></A> <A NAME="item:output"><A NAME="item:output_ITEM_ITEM">output ITEM,...,ITEM</A></A></B></DT>
<DD>
<I>Instance method.</I>
Go through the items.  If an item is an arrayref, treat it like
the array argument to html_tag() and output the result.  If an item
is a text string, escape the text and output the result.  Like this:

<FONT SIZE=3 FACE="courier"><PRE>
     output $HTML [A, HREF=&gt;$url], &quot;Here's my $caption!&quot;, [_A];
</PRE></FONT>
</DL>



<P><HR>
<A NAME="Chocolate"><H3><A HREF="#__TOP__"><IMG SRC="icons/h2bullet.gif" ALT="Top" BORDER="0"></A> Chocolate</H3></A>



<DL>
<P><DT><B><A HREF="#__TOP__"><IMG SRC="icons/itembullet.gif" ALT="Top" BORDER="0"></A> <A NAME="item:accept_tag"><A NAME="item:accept_tag_TAG">accept_tag TAG</A></A></B></DT>
<DD>
<I>Class method.</I>
Declares that the tag is to be accepted as valid HTML (if it isn't already).
For example, this...

<FONT SIZE=3 FACE="courier"><PRE>
     # Make sure methods MARQUEE and _MARQUEE are compiled on demand:
     HTML::Stream-&gt;accept_tag('MARQUEE'); 
</PRE></FONT>

<P>...gives the Chocolate Interface permission to create (via AUTOLOAD)
definitions for the MARQUEE and _MARQUEE methods, so you can then say:

<FONT SIZE=3 FACE="courier"><PRE>
     $HTML -&gt; MARQUEE -&gt; t(&quot;Hi!&quot;) -&gt; _MARQUEE;
</PRE></FONT>

<P>If you want to set the default attribute of the tag as well, you can
do so via the set_tag() method instead; it will effectively do an
accept_tag() as well.

<FONT SIZE=3 FACE="courier"><PRE>
     # Make sure methods MARQUEE and _MARQUEE are compiled on demand,
     #   *and*, set the characteristics of that tag.
     HTML::Stream-&gt;set_tag('MARQUEE', Newlines=&gt;9);
</PRE></FONT>
<P><DT><B><A HREF="#__TOP__"><IMG SRC="icons/itembullet.gif" ALT="Top" BORDER="0"></A> <A NAME="item:private_tags">private_tags</A></B></DT>
<DD>
<I>Instance method.</I>
Normally, HTML streams use a reference to a global table of tag
information to determine how to do such things as auto-formatting,
and modifications made to that table by <CODE>set_tag</CODE> will
affect everyone.


<P>However, if you want an HTML stream to have a private copy of that
table to munge with, just send it this message after creating it.  
Like this:

<FONT SIZE=3 FACE="courier"><PRE>
    my $HTML = new HTML::Stream \*STDOUT;
    $HTML-&gt;private_tags;
</PRE></FONT>

<P>Then, you can say stuff like:

<FONT SIZE=3 FACE="courier"><PRE>
    $HTML-&gt;set_tag('PRE',   Newlines=&gt;0);
    $HTML-&gt;set_tag('BLINK', Newlines=&gt;9);
</PRE></FONT>

<P>And it won't affect anyone else's <I>auto-formatting</I> (although they will 
possibly be able to use the BLINK tag method without a fatal
exception <CODE>:-(</CODE> ).


<P>Returns the self object.

<P><DT><B><A HREF="#__TOP__"><IMG SRC="icons/itembullet.gif" ALT="Top" BORDER="0"></A> <A NAME="item:set_tag"><A NAME="item:set_tag_TAG_TAGINFO">set_tag TAG, [TAGINFO...]</A></A></B></DT>
<DD>
<I>Class/instance method.</I>
Accept the given TAG in the Chocolate Interface, and (if TAGINFO
is given) alter its characteristics when being output.



<UL>
<P><LI>
<P><B>If invoked as a class method,</B> this alters the &quot;master tag table&quot;,
and allows a new tag to be supported via an autoloaded method:

<FONT SIZE=3 FACE="courier"><PRE>
     HTML::Stream-&gt;set_tag('MARQUEE', Newlines=&gt;9);
</PRE></FONT>

<P>Once you do this, <I>all</I> HTML streams you open from then on 
will allow that tag to be output in the chocolate interface.

<P><LI>
<P><B>If invoked as an instance method,</B> this alters the &quot;tag table&quot; referenced
by that HTML stream, usually for the purpose of affecting things like
the auto-formatting on that HTML stream.  


<P><B>Warning:</B> by default, an HTML stream just references the &quot;master tag table&quot; 
(this makes <CODE>new()</CODE> more efficient), so <I>by default, the 
instance method will behave exactly like the class method.</I>

<FONT SIZE=3 FACE="courier"><PRE>
     my $HTML = new HTML::Stream \*STDOUT;
     $HTML-&gt;set_tag('BLINK', Newlines=&gt;0);  # changes it for others!
</PRE></FONT>

<P>If you want to diddle with <I>one</I> stream's auto-formatting <I>only,</I> 
you'll need to give that stream its own <I>private</I> tag table.  Like this:

<FONT SIZE=3 FACE="courier"><PRE>
     my $HTML = new HTML::Stream \*STDOUT;
     $HTML-&gt;private_tags;
     $HTML-&gt;set_tag('BLINK', Newlines=&gt;0);  # doesn't affect other streams
</PRE></FONT>

<P><B>Note:</B> this will still force an default entry for BLINK in the <I>master</I> 
tag table: otherwise, we'd never know that it was legal to AUTOLOAD a 
BLINK method.   However, it will only alter the <I>characteristics</I> of the 
BLINK tag (like auto-formatting) in the <I>object's</I> tag table.

</UL>


<P>The TAGINFO, if given, is a set of key=&gt;value pairs with the following 
possible keys:



<DL>
<P><DT><B><A NAME="item:Newlines">Newlines</A></B></DT>
<DD>
Assumed to be a number which encodes how newlines are to be output 
before/after a tag.   The value is the logical OR (or sum) of a set of flags:

<FONT SIZE=3 FACE="courier"><PRE>
     0x01    newline before &lt;TAG&gt;         .&lt;TAG&gt;.     .&lt;/TAG&gt;.    
     0x02    newline after &lt;TAG&gt;          |     |     |      |
     0x04    newline before &lt;/TAG&gt;        1     2     4      8
     0x08    newline after &lt;/TAG&gt;    
</PRE></FONT>

<P>Hence, to output BLINK environments which are preceded/followed by newlines:

<FONT SIZE=3 FACE="courier"><PRE>
     set_tag HTML::Stream 'BLINK', Newlines=&gt;9;
</PRE></FONT>
</DL>


<P>Returns the self object on success.

<P><DT><B><A HREF="#__TOP__"><IMG SRC="icons/itembullet.gif" ALT="Top" BORDER="0"></A> <A NAME="item:tags">tags</A></B></DT>
<DD>
<I>Class/instance method.</I>
Returns an unsorted list of all tags in the class/instance tag table 
(see <CODE>set_tag</CODE> for class/instance method differences).

</DL>



<P><HR>
<A NAME="SUBCLASSES"><H2><A HREF="#__TOP__"><IMG SRC="icons/h1bullet.gif" ALT="Top" BORDER="0"></A> SUBCLASSES</H2></A>



<P><HR>
<A NAME="HTML_Stream_Latin1"><H3><A HREF="#__TOP__"><IMG SRC="icons/h2bullet.gif" ALT="Top" BORDER="0"></A> HTML::Stream::Latin1</H3></A>


<P>A small, public package for outputting Latin-1 markup.  Its
default auto-escape function is <CODE>LATIN_1</CODE>, which tries to output
the mnemonic entity markup (e.g., <CODE>&amp;ccedil;</CODE>) for ISO-8859-1 characters.


<P>So using HTML::Stream::Latin1 like this:

<FONT SIZE=3 FACE="courier"><PRE>
    use HTML::Stream;
    
    $HTML = new HTML::Stream::Latin1 \*STDOUT;
    output $HTML &quot;\253A right angle is 90\260, \277No?\273\n&quot;;
</PRE></FONT>

<P>Prints this:

<FONT SIZE=3 FACE="courier"><PRE>
    &amp;laquo;A right angle is 90&amp;deg;, &amp;iquest;No?&amp;raquo;
</PRE></FONT>

<P>Instead of what HTML::Stream would print, which is this:

<FONT SIZE=3 FACE="courier"><PRE>
    &amp;#171;A right angle is 90&amp;#176;, &amp;#191;No?&amp;#187;
</PRE></FONT>

<P><B>Warning:</B> a lot of Latin-1 HTML markup is not recognized by older 
browsers (e.g., Netscape 2.0).  Consider using HTML::Stream; it will output 
the decimal entities which currently seem to be more &quot;portable&quot;.


<P><B>Note:</B> using this class &quot;requires&quot; that you have HTML::Entities.



<P><HR>
<A NAME="PERFORMANCE"><H2><A HREF="#__TOP__"><IMG SRC="icons/h1bullet.gif" ALT="Top" BORDER="0"></A> PERFORMANCE</H2></A>


<P>Slower than I'd like.  Both the output() method and the various &quot;tag&quot; 
methods seem to run about 5 times slower than the old 
just-hardcode-the-darn stuff approach.  That is, in general, this:

<FONT SIZE=3 FACE="courier"><PRE>
    ### Approach #1...
    tag  $HTML 'A', HREF=&gt;&quot;$href&quot;;
    tag  $HTML 'IMG', SRC=&gt;&quot;logo.gif&quot;, ALT=&gt;&quot;LOGO&quot;;
    text $HTML $caption;
    tag  $HTML '_A';
    text $HTML $a_lot_of_text;
</PRE></FONT>

<P>And this:

<FONT SIZE=3 FACE="courier"><PRE>
    ### Approach #2...
    output $HTML [A, HREF=&gt;&quot;$href&quot;], 
	         [IMG, SRC=&gt;&quot;logo.gif&quot;, ALT=&gt;&quot;LOGO&quot;],
		 $caption,
		 [_A];
    output $HTML $a_lot_of_text;
</PRE></FONT>

<P>And this:

<FONT SIZE=3 FACE="courier"><PRE>
    ### Approach #3...
    $HTML -&gt; A(HREF=&gt;&quot;$href&quot;)
	  -&gt; IMG(SRC=&gt;&quot;logo.gif&quot;, ALT=&gt;&quot;LOGO&quot;)
	  -&gt; t($caption)
	  -&gt; _A
          -&gt; t($a_lot_of_text);
</PRE></FONT>

<P>Each run about 5x slower than this:

<FONT SIZE=3 FACE="courier"><PRE>
    ### Approach #4...
    print '&lt;A HREF=&quot;', html_escape($href), '&gt;',
          '&lt;IMG SRC=&quot;logo.gif&quot; ALT=&quot;LOGO&quot;&gt;',
  	  html_escape($caption),
          '&lt;/A&gt;';
    print html_escape($a_lot_of_text);
</PRE></FONT>

<P>Of course, I'd much rather use any of first three <I>(especially #3)</I> 
if I had to get something done right in a hurry.  Or did you not notice
the typo in approach #4?  <CODE>;-)</CODE>


<P>(BTW, thanks to Benchmark:: for allowing me to... er... benchmark stuff.)



<P><HR>
<A NAME="VERSION"><H2><A HREF="#__TOP__"><IMG SRC="icons/h1bullet.gif" ALT="Top" BORDER="0"></A> VERSION</H2></A>


<P>$Id: Stream.pm,v 1.54 2001/08/20 20:33:26 eryq Exp $



<P><HR>
<A NAME="CHANGE_LOG"><H2><A HREF="#__TOP__"><IMG SRC="icons/h1bullet.gif" ALT="Top" BORDER="0"></A> CHANGE LOG</H2></A>



<DL>
<P><DT><B><A HREF="#__TOP__"><IMG SRC="icons/itembullet.gif" ALT="Top" BORDER="0"></A> <A NAME="item:Version"><A NAME="item:Version_1_54_2001_08_20">Version 1.54   (2001/08/20)</A></A></B></DT>
<DD>
The terms-of-use have been placed in the distribution file &quot;COPYING&quot;.  
Also, small documentation tweaks were made.

<P><DT><B><A HREF="#__TOP__"><IMG SRC="icons/itembullet.gif" ALT="Top" BORDER="0"></A> <A NAME="item:Version"><A NAME="item:Version_1_51_2001_08_16">Version 1.51   (2001/08/16)</A></A></B></DT>
<DD>
No real changes to code; just improved documentation,
and removed HTML::Entities and HTML::Parser from ./etc
at CPAN's request.

<P><DT><B><A HREF="#__TOP__"><IMG SRC="icons/itembullet.gif" ALT="Top" BORDER="0"></A> <A NAME="item:Version"><A NAME="item:Version_1_47_2000_06_10">Version 1.47   (2000/06/10)</A></A></B></DT>
<DD>
No real changes to code; just improved documentation.

<P><DT><B><A HREF="#__TOP__"><IMG SRC="icons/itembullet.gif" ALT="Top" BORDER="0"></A> <A NAME="item:Version"><A NAME="item:Version_1_45_1999_02_09">Version 1.45   (1999/02/09)</A></A></B></DT>
<DD>
Cleanup for Perl 5.005: removed duplicate typeglob assignments.

<P><DT><B><A HREF="#__TOP__"><IMG SRC="icons/itembullet.gif" ALT="Top" BORDER="0"></A> <A NAME="item:Version"><A NAME="item:Version_1_44_1998_01_14">Version 1.44   (1998/01/14)</A></A></B></DT>
<DD>
Win95 install (5.004) now works.
Added SYNOPSIS to POD.

<P><DT><B><A HREF="#__TOP__"><IMG SRC="icons/itembullet.gif" ALT="Top" BORDER="0"></A> <A NAME="item:Version"><A NAME="item:Version_1_41_1998_01_02">Version 1.41   (1998/01/02)</A></A></B></DT>
<DD>
Removed $&amp; for efficiency.
<I>Thanks, Andreas!</I>


<P>Added support for OPTION, and default now puts newlines after SELECT 
and /SELECT.  Also altered &quot;TELEM&quot; syntax to put newline after end-tags 
of list element tags (like /OPTION, /LI, etc.).  In theory, this change
could produce undesireable results for folks who embed lists inside of PRE 
environments... however, that kind of stuff was done in the days before 
TABLEs; also, you can always turn it off if you really need to.
<I>Thanks to John D Groenveld for these patches.</I>


<P>Added text_nbsp().
<I>Thanks to John D Groenveld for the patch.</I>
This method may also be invoked as nbsp_text() as in the original patch, 
but that's sort of a private tip-of-the-hat to the patch author, and the 
synonym may go away in the future.

<P><DT><B><A HREF="#__TOP__"><IMG SRC="icons/itembullet.gif" ALT="Top" BORDER="0"></A> <A NAME="item:Version"><A NAME="item:Version_1_37_1997_02_09">Version 1.37   (1997/02/09)</A></A></B></DT>
<DD>
No real change; just trying to make CPAN.pm happier.

<P><DT><B><A HREF="#__TOP__"><IMG SRC="icons/itembullet.gif" ALT="Top" BORDER="0"></A> <A NAME="item:Version"><A NAME="item:Version_1_32_1997_01_12">Version 1.32   (1997/01/12)</A></A></B></DT>
<DD>
<B>NEW TOOL for generating Perl code which uses HTML::Stream!</B> 
Check your toolkit for <B>html2perlstream</B>.


<P>Added built-in support for escaping 8-bit characters.


<P>Added <CODE>LATIN_1</CODE> auto-escape, which uses HTML::Entities to generate
mnemonic entities.  This is now the default method for HTML::Stream::Latin1.


<P>Added <CODE>auto_format(),</CODE> 
so you can now turn auto-formatting off/on.


<P>Added <CODE>private_tags()</CODE>, 
so it is now possible for HTML streams to each have their own &quot;private&quot;
copy of the %Tags table, for use by <CODE>set_tag()</CODE>.


<P>Added <CODE>set_tag()</CODE>.  The tags tables may now be modified dynamically so 
as to change how formatting is done on-the-fly.  This will hopefully not
compromise the efficiency of the chocolate interface (until now,
the formatting was compiled into the method itself), and <I>will</I> add
greater flexibility for more-complex programs.


<P>Added POD documentation for all subroutines in the public interface.

<P><DT><B><A HREF="#__TOP__"><IMG SRC="icons/itembullet.gif" ALT="Top" BORDER="0"></A> <A NAME="item:Version"><A NAME="item:Version_1_29_1996_12_10">Version 1.29   (1996/12/10)</A></A></B></DT>
<DD>
Added terminating newline to comment().
<I>Thanks to John D Groenveld for the suggestion and the patch.</I>

<P><DT><B><A HREF="#__TOP__"><IMG SRC="icons/itembullet.gif" ALT="Top" BORDER="0"></A> <A NAME="item:Version"><A NAME="item:Version_1_27_1996_12_10">Version 1.27   (1996/12/10)</A></A></B></DT>
<DD>
Added built-in HTML::Stream::Latin1, which does a very simple encoding
of all characters above ASCII 127.


<P>Fixed bug in accept_tag(), where 'my' variable was shadowing argument.
<I>Thanks to John D Groenveld for the bug report and the patch.</I>

<P><DT><B><A HREF="#__TOP__"><IMG SRC="icons/itembullet.gif" ALT="Top" BORDER="0"></A> <A NAME="item:Version"><A NAME="item:Version_1_26_1996_09_27">Version 1.26   (1996/09/27)</A></A></B></DT>
<DD>
Start of history.

</DL>



<P><HR>
<A NAME="ACKNOWLEDGEMENTS"><H2><A HREF="#__TOP__"><IMG SRC="icons/h1bullet.gif" ALT="Top" BORDER="0"></A> ACKNOWLEDGEMENTS</H2></A>


<P>Warmest thanks to...

<FONT SIZE=3 FACE="courier"><PRE>
    John Buckman           For suggesting that I write an &quot;html2perlstream&quot;,
                           and inspiring me to look at supporting Latin-1.
    Tony Cebzanov          For suggesting that I write an &quot;html2perlstream&quot;
    John D Groenveld       Bug reports, patches, and suggestions
    B. K. Oxley (binkley)  For suggesting the support of &quot;writing to strings&quot;
                           which became the &quot;printable&quot; interface.
</PRE></FONT>


<P><HR>
<A NAME="AUTHOR"><H2><A HREF="#__TOP__"><IMG SRC="icons/h1bullet.gif" ALT="Top" BORDER="0"></A> AUTHOR</H2></A>


<P>Eryq (<I><FILE><A HREF="mailto:eryq@zeegee.com">eryq@zeegee.com</A></FILE></I>).
President, ZeeGee Software Inc. (<I><FILE><A HREF="http://www.zeegee.com">http://www.zeegee.com</A></FILE></I>).


<P>Go to <I><FILE><A HREF="http://www.zeegee.com">http://www.zeegee.com</A></FILE></I> for the latest downloads
and on-line documentation for this module.  


<P>Enjoy.  Yell if it breaks.

<P><HR>
<ADDRESS><FONT SIZE=-1>
Generated Mon Aug 20 16:33:54 2001 by cvu_pod2html
</FONT></ADDRESS>
</FONT></BODY>
</HTML>