/usr/share/doc/libapache2-mod-perl2-doc/docs/2.0/api/Apache2/Directive.html is in libapache2-mod-perl2-doc 2.0.8+httpd24-r1449661-6ubuntu2.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 | <?xml version="1.0" ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title></title>
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<link rev="made" href="mailto:root@localhost" />
</head>
<body style="background-color: white">
<ul id="index">
<li><a href="#NAME">NAME</a></li>
<li><a href="#Synopsis">Synopsis</a></li>
<li><a href="#Description">Description</a></li>
<li><a href="#API">API</a>
<ul>
<li><a href="#args">args</a></li>
<li><a href="#as_hash">as_hash</a></li>
<li><a href="#as_string">as_string</a></li>
<li><a href="#conftree">conftree</a></li>
<li><a href="#directive">directive</a></li>
<li><a href="#filename">filename</a></li>
<li><a href="#first_child">first_child</a></li>
<li><a href="#line_num">line_num</a></li>
<li><a href="#lookup">lookup</a></li>
<li><a href="#next">next</a></li>
<li><a href="#parent">parent</a></li>
</ul>
</li>
<li><a href="#See-Also">See Also</a></li>
<li><a href="#Copyright">Copyright</a></li>
<li><a href="#Authors">Authors</a></li>
</ul>
<h1 id="NAME">NAME</h1>
<p>Apache2::Directive - Perl API for manipulating the Apache configuration tree</p>
<h1 id="Synopsis">Synopsis</h1>
<pre><code> use Apache2::Directive ();
my $tree = Apache2::Directive::conftree();
my $documentroot = $tree->lookup('DocumentRoot');
my $vhost = $tree->lookup('VirtualHost', 'localhost:8000');
my $servername = $vhost->{'ServerName'};
use Data::Dumper;
print Dumper $tree->as_hash;
my $node = $tree;
while ($node) {
print $node->as_string;
#do something with $node
my $directive = $node->directive;
my $args = $node->args;
my $filename = $node->filename;
my $line_num = $node->line_num;
if (my $kid = $node->first_child) {
$node = $kid;
}
elsif (my $next = $node->next) {
$node = $next;
}
else {
if (my $parent = $node->parent) {
$node = $parent->next;
}
else {
$node = undef;
}
}
}</code></pre>
<h1 id="Description">Description</h1>
<p><code>Apache2::Directive</code> provides the Perl API for manipulating the Apache configuration tree</p>
<h1 id="API">API</h1>
<p><code>Apache2::Directive</code> provides the following functions and/or methods:</p>
<h2 id="args"><code>args</code></h2>
<p>Get the arguments for the current directive:</p>
<pre><code> $args = $node->args();</code></pre>
<dl>
<dt id="obj:-node-Apache2::Directive-object">obj: <code>$node</code> ( <code><a>Apache2::Directive object</a></code> )</dt>
<dd>
</dd>
<dt id="ret:-args-string">ret: <code>$args</code> ( string )</dt>
<dd>
<p>Arguments are separated by a whitespace in the string.</p>
</dd>
<dt id="since:-2.0.00">since: 2.0.00</dt>
<dd>
</dd>
</dl>
<p>For example, in <i>httpd.conf</i>:</p>
<pre><code> PerlSwitches -M/opt/lib -M/usr/local/lib -wT</code></pre>
<p>And later:</p>
<pre><code> my $tree = Apache2::Directive::conftree();
my $node = $tree->lookup('PerlSwitches');
my $args = $node->args;</code></pre>
<p><code>$args</code> now contains the string "-M/opt/lib -M/usr/local/lib -wT"</p>
<h2 id="as_hash"><code>as_hash</code></h2>
<p>Get a hash representation of the configuration tree, in a format suitable for inclusion in <Perl> sections.</p>
<pre><code> $config_hash = $conftree->as_hash();</code></pre>
<dl>
<dt id="obj:-conftree-Apache2::Directive-object">obj: <code>$conftree</code> ( <code><a>Apache2::Directive object</a></code> )</dt>
<dd>
<p>The config tree to stringify</p>
</dd>
<dt id="ret:-config_hash-HASH-reference">ret: <code>$config_hash</code> ( HASH reference )</dt>
<dd>
</dd>
<dt id="since:-2.0.001">since: 2.0.00</dt>
<dd>
</dd>
</dl>
<p>For example: in <i>httpd.conf</i>:</p>
<pre><code> <Location /test>
SetHandler perl-script
PerlHandler Test::Module
</Location></code></pre>
<p>And later:</p>
<pre><code> my $tree = Apache2::Directive::conftree();
my $node = $tree->lookup('Location', '/test/');
my $hash = $node->as_hash;</code></pre>
<p><code>$hash</code> now is:</p>
<pre><code> {
'SetHandler' => 'perl-script',
'PerlHandler' => 'Test::Module',
}</code></pre>
<h2 id="as_string"><code>as_string</code></h2>
<p>Get a string representation of the configuration node, in <i>httpd.conf</i> format.</p>
<pre><code> $string = $node->as_string();</code></pre>
<dl>
<dt id="obj:-node-Apache2::Directive-object1">obj: <code>$node</code> ( <code><a>Apache2::Directive object</a></code> )</dt>
<dd>
<p>The config tree to stringify</p>
</dd>
<dt id="ret:-string-string">ret: <code>$string</code> ( string )</dt>
<dd>
</dd>
<dt id="since:-2.0.002">since: 2.0.00</dt>
<dd>
</dd>
</dl>
<p>For example: in <i>httpd.conf</i>:</p>
<pre><code> <Location /test>
SetHandler perl-script
PerlHandler Test::Module
</Location></code></pre>
<p>And later:</p>
<pre><code> my $tree = Apache2::Directive::conftree();
my $node = $tree->lookup('Location', '/test/');
my $string = $node->as_string;</code></pre>
<p><code>$string</code> is now:</p>
<pre><code> SetHandler perl-script
PerlHandler Test::Module</code></pre>
<h2 id="conftree"><code>conftree</code></h2>
<p>Get the root of the configuration tree:</p>
<pre><code> $conftree = Apache2::Directive::conftree();</code></pre>
<dl>
<dt id="obj:-Apache2::Directive-class-name">obj: <code>Apache2::Directive</code> ( class name )</dt>
<dd>
</dd>
<dt id="ret:-conftree-Apache2::Directive-object">ret: <code>$conftree</code> ( <code><a>Apache2::Directive object</a></code> )</dt>
<dd>
</dd>
<dt id="since:-2.0.003">since: 2.0.00</dt>
<dd>
</dd>
</dl>
<h2 id="directive"><code>directive</code></h2>
<p>Get the name of the directive in <code>$node</code>:</p>
<pre><code> $name = $node->directive();</code></pre>
<dl>
<dt id="obj:-node-Apache2::Directive-object2">obj: <code>$node</code> ( <code><a>Apache2::Directive object</a></code> )</dt>
<dd>
</dd>
<dt id="ret:-name-string">ret: <code>$name</code> ( string )</dt>
<dd>
</dd>
<dt id="since:-2.0.004">since: 2.0.00</dt>
<dd>
</dd>
</dl>
<h2 id="filename"><code>filename</code></h2>
<p>Get the <i>filename</i> the configuration node was created from:</p>
<pre><code> $filename = $node->filename();</code></pre>
<dl>
<dt id="obj:-node-Apache2::Directive-object3">obj: <code>$node</code> ( <code><a>Apache2::Directive object</a></code> )</dt>
<dd>
</dd>
<dt id="ret:-filename-string">ret: <code>$filename</code> ( string )</dt>
<dd>
</dd>
<dt id="since:-2.0.005">since: 2.0.00</dt>
<dd>
</dd>
</dl>
<p>For example:</p>
<pre><code> my $tree = Apache2::Directive::conftree();
my $node = $tree->lookup('VirtualHost', 'example.com');
my $filename = $node->filename;</code></pre>
<p><code>$filename</code> is now the full path to the <i>httpd.conf</i> that VirtualHost was defined in.</p>
<p>If the directive was added with <code><a>add_config()</a></code>, the filename will be the path to the <i>httpd.conf</i> that trigerred that Perl code.</p>
<h2 id="first_child"><code>first_child</code></h2>
<p>Get the first child node of this directive:</p>
<pre><code> $child_node = $node->first_child;</code></pre>
<dl>
<dt id="obj:-node-Apache2::Directive-object4">obj: <code>$node</code> ( <code><a>Apache2::Directive object</a></code> )</dt>
<dd>
</dd>
<dt id="ret:-child_node-Apache2::Directive-object">ret: <code>$child_node</code> ( <code><a>Apache2::Directive object</a></code> )</dt>
<dd>
<p>Returns the first child node of <code>$node</code>, <code>undef</code> if there is none</p>
</dd>
<dt id="since:-2.0.006">since: 2.0.00</dt>
<dd>
</dd>
</dl>
<h2 id="line_num"><code>line_num</code></h2>
<p>Get the line number in a <i>filename</i> this node was created at:</p>
<pre><code> $lineno = $node->line_num();</code></pre>
<dl>
<dt id="obj:-node-Apache2::Directive-object5">obj: <code>$node</code> ( <code><a>Apache2::Directive object</a></code> )</dt>
<dd>
</dd>
<dt id="arg1:-lineno-integer">arg1: <code>$lineno</code> (integer)</dt>
<dd>
</dd>
<dt id="since:-2.0.007">since: 2.0.00</dt>
<dd>
</dd>
</dl>
<h2 id="lookup"><code>lookup</code></h2>
<p>Get the node(s) matching a certain value.</p>
<pre><code> $node = $conftree->lookup($directive, $args);
@nodes = $conftree->lookup($directive, $args);</code></pre>
<dl>
<dt id="obj:-conftree-Apache2::Directive-object1">obj: <code>$conftree</code> ( <code><a>Apache2::Directive object</a></code> )</dt>
<dd>
<p>The config tree to stringify</p>
</dd>
<dt id="arg1:-directive-string">arg1: <code>$directive</code> ( string )</dt>
<dd>
<p>The name of the directive to search for</p>
</dd>
<dt id="opt-arg2:-args-string">opt arg2: <code>args</code> ( string )</dt>
<dd>
<p>Optional args to the directive to filter for</p>
</dd>
<dt id="ret:-string-string-ARRAY-of-HASH-refs">ret: <code>$string</code> ( string / ARRAY of HASH refs )</dt>
<dd>
<p>In LIST context, it returns all matching nodes.</p>
<p>In SCALAR context, it returns only the first matching node.</p>
<p>If called with only <code>$directive</code> value, this method returns all nodes from that directive. For example:</p>
<pre><code> @Alias = $conftree->lookup('Alias');</code></pre>
<p>returns all nodes for <code>Alias</code> directives.</p>
<p>If called with an extra <code>$args</code> argument, it returns only nodes where both the directive and the args matched. For example:</p>
<pre><code> $VHost = $tree->lookup('VirtualHost', '_default_:8000');</code></pre>
</dd>
<dt id="since:-2.0.008">since: 2.0.00</dt>
<dd>
</dd>
</dl>
<h2 id="next"><code>next</code></h2>
<p>Get the next directive node in the tree:</p>
<pre><code> $next_node = $node->next();</code></pre>
<dl>
<dt id="obj:-node-Apache2::Directive-object6">obj: <code>$node</code> ( <code><a>Apache2::Directive object</a></code> )</dt>
<dd>
</dd>
<dt id="ret:-next_node-Apache2::Directive-object">ret: <code>$next_node</code> ( <code><a>Apache2::Directive object</a></code> )</dt>
<dd>
<p>Returns the next sibling of <code>$node</code>, <code>undef</code> if there is none</p>
</dd>
<dt id="since:-2.0.009">since: 2.0.00</dt>
<dd>
</dd>
</dl>
<h2 id="parent"><code>parent</code></h2>
<p>Get the parent node of this directive:</p>
<pre><code> $parent_node = $node->parent();</code></pre>
<dl>
<dt id="obj:-node-Apache2::Directive-object7">obj: <code>$node</code> ( <code><a>Apache2::Directive object</a></code> )</dt>
<dd>
</dd>
<dt id="ret:-parent_node-Apache2::Directive-object">ret: <code>parent_node</code> ( <code><a>Apache2::Directive object</a></code> )</dt>
<dd>
<p>Returns the parent of <code>$node</code>, <code>undef</code> if this node is the root node</p>
</dd>
<dt id="since:-2.0.0010">since: 2.0.00</dt>
<dd>
</dd>
</dl>
<h1 id="See-Also">See Also</h1>
<p><a>mod_perl 2.0 documentation</a>.</p>
<h1 id="Copyright">Copyright</h1>
<p>mod_perl 2.0 and its core modules are copyrighted under The Apache Software License, Version 2.0.</p>
<h1 id="Authors">Authors</h1>
<p><a>The mod_perl development team and numerous contributors</a>.</p>
</body>
</html>
|