Debian Codegraph @

DOC/HTML/SGMLSpm/sgmls.html

raw symbols ◀ ▶
Source reconstructed at patch state 0 of 1 — not the installed (fully patched) source.
1 Debian patch touch this file
1 <HTML>
2 <HEAD>
3 <TITLE>How do I use SGMLS.pm?</TITLE>
4 </HEAD>
5 <BODY>
6
7 <P><B>Links</B>: <A HREF=sgmlsevent.html>Next</A> <A HREF=perl5.html>Previous</A> <A HREF=sgmlspm.html>Up</A> <A HREF=sgmlspm.html>Top</A></P>
8
9 <H1>How do I use <A HREF=sgmlspm.html><TT>SGMLS.pm</TT></A>?</H1>
10
11 <P>First, you need to copy the file <A HREF=sgmlspm.html><TT>SGMLS.pm</TT></A> to a directory where
12 perl can find it (on a Unix system, it might be
13 <TT>/usr/lib/perl5</TT> or
14 <TT>/usr/local/lib/perl5</TT>, or whatever the environment
15 variable <TT>PERL5LIB</TT> is set to) and make certain that it
16 is world-readable.</P>
17
18 <P>Next, near the top of your <A HREF="http://www.metronet.com/0/perlinfo/perl5/manual/perl.html"><TT>perl5</TT></A> program, type the following
19 line:</P>
20
21 <P>
22 <PRE>use SGMLS;</PRE>
23 </P>
24 <P>You must then open up a file handle from which <A HREF=sgmlspm.html><TT>SGMLS.pm</TT></A> can read the
25 data from an <TT>sgmls</TT> or <A HREF="http://www.jclark.com/sp.html"><TT>nsgmls</TT></A> process, unless you are reading from
26 a standard handle like <TT>STDIN</TT> -- for example,
27 if you are piping the output from <TT>sgmls</TT> to a <A HREF="http://www.metronet.com/0/perlinfo/perl5/manual/perl.html"><TT>perl5</TT></A> script, using
28 something like</P>
29
30 <P>
31 <PRE>sgmls foo.sgml | perl myscript.pl</PRE>
32 </P>
33 <P>then the predefined filehandle <TT>STDIN</TT> will be
34 sufficient. In DOS, you might want to dump the sgmls output to a file
35 and use it as standard input (or open it explicitly in perl), and in
36 Unix, you might actually want to open a pipe or socket for the input.
37 <A HREF=sgmlspm.html><TT>SGMLS.pm</TT></A> doesn't need to seek, so any input stream should
38 work.</P>
39
40 <P>To parse the <TT>sgmls</TT> or <A HREF="http://www.jclark.com/sp.html"><TT>nsgmls</TT></A> output from the handle, create
41 a new object instance of the <TT>SGMLS</TT> class with
42 the handle as an argument, i.e.</P>
43
44 <P>
45 <PRE>$parse = new SGMLS(STDIN);</PRE>
46 </P>
47 <P>(You may create more than one <TT>SGMLS</TT>
48 object at once, but each object <EM>must</EM> have a
49 unique handle pointing to a unique stream, or
50 <EM>chaos</EM> will result.) Now, you can retrieve and
51 process events using the <TT>next_event</TT> method:</P>
52
53 <P>
54 <PRE>while ($event = $parse->next_event) {
55 #do something with each event
56 }</PRE>
57 </P>
58
59 <P><B>Links</B>: <A HREF=sgmlsevent.html>Next</A> <A HREF=perl5.html>Previous</A> <A HREF=sgmlspm.html>Up</A> <A HREF=sgmlspm.html>Top</A></P>
60
61
62 <ADDRESS>David Megginson <A HREF="mailto:[email protected]">&lt;[email protected]&gt;</A></ADDRESS>
63 </BODY>
64 </HTML>