1
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
2
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
4
<title>Pod::Simple::Methody - perldoc.perl.org</title>
5
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
6
<meta http-equiv="Content-Language" content="en-gb" />
7
<link href="../../css.css" rel="stylesheet" rev="stylesheet" type="text/css" media="screen" />
10
<script language="JavaScript" type="text/javascript" src="../../label.js"></script>
12
<script language="JavaScript">
17
<body onLoad="showToolbars();loadLabels()">
20
<div id="pageHeaderLogo">
21
<img src="../../onion.gif">
23
<div id="pageHeaderText">
24
<a href="http://perldoc.perl.org">perldoc.perl.org</a>
30
<div id="leftContent">
32
<a href="#" onClick="closeLeft()" title="Hide navigation" onmouseover="leftCloseIcon.src='../../close_purple.gif';" onmouseout="leftCloseIcon.src='../../close_blue.gif';"><img src="../../close_blue.gif" name="leftCloseIcon" id="leftCloseIcon" border=0></a>
36
<li><a href="../../index-overview.html">Overview</a></li>
37
<li><a href="../../index-tutorials.html">Tutorials</a></li>
38
<li><a href="../../index-faq.html">FAQs</a></li>
39
<li><a href="../../index-history.html">History / Changes</a></li>
40
<li><a href="../../index-licence.html">Licence</a></li>
44
<li><a href="../../index-language.html">Language</a></li>
45
<li><a href="../../index-functions.html">Functions</a></li>
46
<li><a href="../../perlop.html">Operators</a></li>
47
<li><a href="../../perlvar.html">Special variables</a></li>
48
<li><a href="../../index-pragmas.html">Pragmas</a></li>
49
<li><a href="../../index-modules-A.html">Core modules</a></li>
50
<li><a href="../../index-utilities.html">Utilities</a></li>
51
<li><a href="../../index-internals.html">Internals</a></li>
52
<li><a href="../../index-platforms.html">Platform specific</a></li>
56
<li><a href="http://search.cpan.org">CPAN</a></li>
57
<li><a href="http://www.perl.org">Perl.org</a></li>
58
<li><a href="http://www.perl.com">Perl.com</a></li>
59
<li><a href="http://perlbuzz.com">Perl Buzz</a></li>
60
<li><a href="http://www.perlfoundation.org/perl5/index.cgi">Perl 5 Wiki</a></li>
61
<li><a href="http://jobs.perl.org">Perl Jobs</a></li>
62
<li><a href="http://www.pm.org">Perl Mongers</a></li>
63
<li><a href="http://www.perlmonks.org">Perl Monks</a></li>
64
<li><a href="http://planet.perl.org">Planet Perl</a></li>
65
<li><a href="http://use.perl.org">Use Perl</a></li>
69
<li>Site maintained by<br><a href="http://perl.jonallen.info">Jon Allen</a>
70
(<a href="http://perl.jonallen.info">JJ</a>)</li>
71
<li class="spaced">Last updated on<br>23 December 2007</li>
72
<li class="spaced">See the <a href="http://perl.jonallen.info/projects/perldoc">project page</a> for
79
<div id="centerContent">
80
<div id="contentHeader">
81
<div id="contentHeaderLeft"><a href="#" onClick="showLeft()">Show navigation</a></div>
82
<div id="contentHeaderCentre">-- Perl 5.10.0 documentation --</div>
83
<div id="contentHeaderRight"><a href="#" onClick="showRight()">Show toolbar</a></div>
85
<div id="breadCrumbs"><a href="../../index.html">Home</a> > <a href="../../index-modules-A.html">Core modules</a> > <a href="../../index-modules-P.html">P</a> > Pod::Simple::Methody</div>
86
<script language="JavaScript">fromSearch();</script>
87
<div id="contentBody"><div class="title_container"><div class="page_title">Pod::Simple::Methody</div></div><ul><li><a href="#NAME">NAME</a><li><a href="#SYNOPSIS">SYNOPSIS</a><li><a href="#DESCRIPTION">DESCRIPTION</a><li><a href="#METHOD-CALLING">METHOD CALLING</a><li><a href="#SEE-ALSO">SEE ALSO</a><li><a href="#COPYRIGHT-AND-DISCLAIMERS">COPYRIGHT AND DISCLAIMERS</a><li><a href="#AUTHOR">AUTHOR</a></ul><a name="NAME"></a><h1>NAME</h1>
88
<p>Pod::Simple::Methody -- turn Pod::Simple events into method calls</p>
89
<a name="SYNOPSIS"></a><h1>SYNOPSIS</h1>
90
<pre class="verbatim"> <a class="l_k" href="../../functions/require.html">require</a> <span class="n">5</span><span class="sc">;</span>
91
<a class="l_k" href="../../functions/use.html">use</a> <span class="w">strict</span><span class="sc">;</span>
92
<a name="package-SomePodFormatter"></a> package <span class="i">SomePodFormatter</span><span class="sc">;</span>
93
<a class="l_k" href="../../functions/use.html">use</a> <span class="w">base</span> <span class="q">qw(Pod::Simple::Methody)</span><span class="sc">;</span></pre>
94
<pre class="verbatim"><a name="handle_text"></a> sub <span class="m">handle_text</span> <span class="s">{</span>
95
<a class="l_k" href="../../functions/my.html">my</a><span class="s">(</span><span class="i">$self</span><span class="cm">,</span> <span class="i">$text</span><span class="s">)</span> = <span class="i">@_</span><span class="sc">;</span>
97
<span class="s">}</span></pre>
98
<pre class="verbatim"><a name="start_head1"></a> sub <span class="m">start_head1</span> <span class="s">{</span>
99
<a class="l_k" href="../../functions/my.html">my</a><span class="s">(</span><span class="i">$self</span><span class="cm">,</span> <span class="i">$attrs</span><span class="s">)</span> = <span class="i">@_</span><span class="sc">;</span>
101
<span class="s">}</span>
102
<a name="end_head1"></a> sub <span class="m">end_head1</span> <span class="s">{</span>
103
<a class="l_k" href="../../functions/my.html">my</a><span class="s">(</span><span class="i">$self</span><span class="s">)</span> = <span class="i">@_</span><span class="sc">;</span>
105
<span class="s">}</span></pre>
106
<p>...and start_/end_ methods for whatever other events you want to catch.</p>
107
<a name="DESCRIPTION"></a><h1>DESCRIPTION</h1>
109
interest to people writing Pod formatters based on Pod::Simple.</p>
110
<p>This class (which is very small -- read the source) overrides
111
Pod::Simple's _handle_element_start, _handle_text, and
112
_handle_element_end methods so that parser events are turned into method
113
calls. (Otherwise, this is a subclass of <a href="../../Pod/Simple.html">Pod::Simple</a> and inherits all
115
<p>You can use this class as the base class for a Pod formatter/processor.</p>
116
<a name="METHOD-CALLING"></a><h1>METHOD CALLING</h1>
117
<p>When Pod::Simple sees a "=head1 Hi there", for example, it basically does
119
<pre class="verbatim"> <span class="i">$parser</span><span class="i">->_handle_element_start</span><span class="s">(</span> <span class="q">"head1"</span><span class="cm">,</span> \<span class="i">%attributes</span> <span class="s">)</span><span class="sc">;</span>
120
<span class="i">$parser</span><span class="i">->_handle_text</span><span class="s">(</span> <span class="q">"Hi there"</span> <span class="s">)</span><span class="sc">;</span>
121
<span class="i">$parser</span><span class="i">->_handle_element_end</span><span class="s">(</span> <span class="q">"head1"</span> <span class="s">)</span><span class="sc">;</span></pre>
122
<p>But if you subclass Pod::Simple::Methody, it will instead do this
123
when it sees a "=head1 Hi there":</p>
124
<pre class="verbatim"> <span class="i">$parser</span><span class="i">->start_head1</span><span class="s">(</span> \<span class="i">%attributes</span> <span class="s">)</span> if <span class="i">$parser</span><span class="i">->can</span><span class="s">(</span><span class="q">'start_head1'</span><span class="s">)</span><span class="sc">;</span>
125
<span class="i">$parser</span><span class="i">->handle_text</span><span class="s">(</span> <span class="q">"Hi there"</span> <span class="s">)</span> if <span class="i">$parser</span><span class="i">->can</span><span class="s">(</span><span class="q">'handle_text'</span><span class="s">)</span><span class="sc">;</span>
126
<span class="i">$parser</span><span class="i">->end_head1</span><span class="s">(</span><span class="s">)</span> if <span class="i">$parser</span><span class="i">->can</span><span class="s">(</span><span class="q">'end_head1'</span><span class="s">)</span><span class="sc">;</span></pre>
127
<p>If Pod::Simple sends an event where the element name has a dash,
128
period, or colon, the corresponding method name will have a underscore
129
in its place. For example, "foo.bar:baz" becomes start_foo_bar_baz
130
and end_foo_bar_baz.</p>
131
<p>See the source for Pod::Simple::Text for an example of using this class.</p>
132
<a name="SEE-ALSO"></a><h1>SEE ALSO</h1>
133
<p><a href="../../Pod/Simple.html">Pod::Simple</a>, <a href="../../Pod/Simple/Subclassing.html">Pod::Simple::Subclassing</a></p>
134
<a name="COPYRIGHT-AND-DISCLAIMERS"></a><h1>COPYRIGHT AND DISCLAIMERS</h1>
135
<p>Copyright (c) 2002 Sean M. Burke. All rights reserved.</p>
136
<p>This library is free software; you can redistribute it and/or modify it
137
under the same terms as Perl itself.</p>
138
<p>This program is distributed in the hope that it will be useful, but
139
without any warranty; without even the implied warranty of
140
merchantability or fitness for a particular purpose.</p>
141
<a name="AUTHOR"></a><h1>AUTHOR</h1>
142
<p>Sean M. Burke <code class="inline"><span class="w">sburke</span><span class="i">@cpan</span>.<span class="w">org</span></code>
145
<div id="contentFooter"><a href="http://www.perl.org"><img src="../../perlpowered.png" border=0></a></div>
150
<div id="rightContent">
152
<a href="#" onClick="closeRight()" title="Hide toolbar" onmouseover="rightCloseIcon.src='../../close_purple.gif';" onmouseout="rightCloseIcon.src='../../close_blue.gif';"><img src="../../close_blue.gif" name="rightCloseIcon" id="rightCloseIcon" border=0></a>
156
<form action="../../search.html" name="perldoc_search">
157
<input type="text" name="q" size="10" class="grey"><br>
158
<!--<select name="r"><option value="1" selected>Go to top result<option value="0">Show results list</select>-->
161
<script language="JavaScript" type="text/javascript" src="/perl-version.js"></script>
164
<a href="#" onClick="addLabel('Pod::Simple::Methody','Pod/Simple/Methody.html')">Add this page</a>
166
<div class="labels" id="labels">