Sophie

Sophie

distrib > Arklinux > devel > x86_64 > media > main > by-pkgid > 39ad2f9704867344e98d41c61c92667a > files > 50

perl-SGMLSpm-1.03ii-13ark.noarch.rpm

<HTML>
<HEAD>
<TITLE>How do I use push_output?</TITLE>
</HEAD>
<BODY>

<P><B>Links</B>: <A HREF=popoutput.html>Next</A> <A HREF=output.html>Previous</A> <A HREF=sgmlspl.html>Up</A> <A HREF=sgmlspl.html>Top</A></P>

<H1>How do I use <TT>push_output</TT>?</H1>

<P>The subroutine
<TT>push_output(<IT>type</IT>[,<IT>data</IT>])</TT>
takes two arguments: the <IT>type</IT>, which is always
required, and the <IT>data</IT>, which is needed for
certain types of output.  Table 3 lists the different types which you
can push onto the output stack.</P>


<H3>Table 3: Types for <TT>push_output</TT></H3>

<HR>
<DL>
<DT><B>Type</B></DT>
<DD><TT>'handle'</TT></DD>
<DT><B>Data</B></DT>
<DD>a filehandle</DD>
<DT><B>Description</B></DT>
<DD>Send all output to the supplied filehandle.</DD>

</DL>
<HR>


<DL>
<DT><B>Type</B></DT>
<DD><TT>'file'</TT></DD>
<DT><B>Data</B></DT>
<DD>a filename</DD>
<DT><B>Description</B></DT>
<DD>Open the supplied file for writing, erasing its current
contents (if any), and send all output to it.</DD>

</DL>
<HR>


<DL>
<DT><B>Type</B></DT>
<DD><TT>'append'</TT></DD>
<DT><B>Data</B></DT>
<DD>a filename</DD>
<DT><B>Description</B></DT>
<DD>Open the supplied file for writing and append all output to its
current contents.</DD>

</DL>
<HR>


<DL>
<DT><B>Type</B></DT>
<DD><TT>'pipe'</TT></DD>
<DT><B>Data</B></DT>
<DD>a shell command</DD>
<DT><B>Description</B></DT>
<DD>Pipe all output to the supplied shell command.</DD>

</DL>
<HR>


<DL>
<DT><B>Type</B></DT>
<DD><TT>'string'</TT></DD>
<DT><B>Data</B></DT>
<DD>a string [optional]</DD>
<DT><B>Description</B></DT>
<DD>Append all output to the supplied string, which will be
returned by <TT>pop_output</TT>.</DD>

</DL>
<HR>


<DL>
<DT><B>Type</B></DT>
<DD><TT>'nul'</TT></DD>
<DT><B>Data</B></DT>
<DD>[none]</DD>
<DT><B>Description</B></DT>
<DD>Ignore all output.</DD>

</DL>
<HR>


<P>Because the output is stack-based, you do not lose the previous
output destination when you push a new one.  This is especially
convenient for dealing with data in tree-structures, like <A HREF="http://www.sil.org/sgml/sgml.html"><B>SGML</B></A> data
-- for example, you can capture the contents of sub-elements as
strings, ignore certain types of elements, and split the output from
one <A HREF="http://www.sil.org/sgml/sgml.html"><B>SGML</B></A> parse into a series of sub-files.  Here are some examples:</P>

<P>
<PRE>push_output('string');                  # append output to an empty string
push_output('file','/tmp/foo');         # send output to this file
push_output('pipe','mail webmaster');   # mail output to 'webmaster' (!!)
push_output('nul');                     # just ignore all output</PRE>
</P>

<P><B>Links</B>: <A HREF=popoutput.html>Next</A> <A HREF=output.html>Previous</A> <A HREF=sgmlspl.html>Up</A> <A HREF=sgmlspl.html>Top</A></P>


<ADDRESS>David Megginson <A HREF="mailto:dmeggins@aix1.uottawa.ca">&lt;dmeggins@aix1.uottawa.ca&gt;</A></ADDRESS>
</BODY>
</HTML>