docs::api::Apache2::Directive - Online Linux Manual PageSection : 3
Updated : 2021-01-26
Source : perl v5.32.1
Note : User Contributed Perl Documentation
NAMEApache2::Directive − Perl API for manipulating the Apache configuration tree
Synopsis 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;
}
}
}
DescriptionApache2::Directive provides the Perl API for manipulating the Apache configuration tree
APIApache2::Directive provides the following functions and/or methods:
argsGet the arguments for the current directive: $args = $node−>args();
obj: $node ( Apache2::Directive object ) ret: $args ( string ) Arguments are separated by a whitespace in the string. since: 2.0.00 For example, in httpd.conf: PerlSwitches −M/opt/lib −M/usr/local/lib −wT
And later: my $tree = Apache2::Directive::conftree();
my $node = $tree−>lookup('PerlSwitches');
my $args = $node−>args;
$args now contains the string ‟−M/opt/lib −M/usr/local/lib −wT”
as_hashGet a hash representation of the configuration tree, in a format suitable for inclusion in <Perl> sections. $config_hash = $conftree−>as_hash();
obj: $conftree ( Apache2::Directive object ) The config tree to stringify ret: $config_hash ( HASH reference ) since: 2.0.00 For example: in httpd.conf: <Location /test>
SetHandler perl−script
PerlHandler Test::Module
</Location>
And later: my $tree = Apache2::Directive::conftree();
my $node = $tree−>lookup('Location', '/test/');
my $hash = $node−>as_hash;
$hash now is: {
'SetHandler' => 'perl−script',
'PerlHandler' => 'Test::Module',
}
as_stringGet a string representation of the configuration node, in httpd.conf format. $string = $node−>as_string();
obj: $node ( Apache2::Directive object ) The config tree to stringify ret: $string ( string ) since: 2.0.00 For example: in httpd.conf: <Location /test>
SetHandler perl−script
PerlHandler Test::Module
</Location>
And later: my $tree = Apache2::Directive::conftree();
my $node = $tree−>lookup('Location', '/test/');
my $string = $node−>as_string;
$string is now: SetHandler perl−script
PerlHandler Test::Module
conftreeGet the root of the configuration tree: $conftree = Apache2::Directive::conftree();
obj: Apache2::Directive ( class name ) ret: $conftree ( Apache2::Directive object ) since: 2.0.00
directiveGet the name of the directive in $node: $name = $node−>directive();
obj: $node ( Apache2::Directive object ) ret: $name ( string ) since: 2.0.00
filenameGet the filename the configuration node was created from: $filename = $node−>filename();
obj: $node ( Apache2::Directive object ) ret: $filename ( string ) since: 2.0.00 For example: my $tree = Apache2::Directive::conftree();
my $node = $tree−>lookup('VirtualHost', 'example.com');
my $filename = $node−>filename;
$filename is now the full path to the httpd.conf that VirtualHost was defined in. If the directive was added with add_config(), the filename will be the path to the httpd.conf that trigerred that Perl code.
first_childGet the first child node of this directive: $child_node = $node−>first_child;
obj: $node ( Apache2::Directive object ) ret: $child_node ( Apache2::Directive object ) Returns the first child node of $node, undef if there is none since: 2.0.00
line_numGet the line number in a filename this node was created at: $lineno = $node−>line_num();
obj: $node ( Apache2::Directive object ) arg1: $lineno (integer) since: 2.0.00
lookupGet the node(s) matching a certain value. $node = $conftree−>lookup($directive, $args);
@nodes = $conftree−>lookup($directive, $args);
obj: $conftree ( Apache2::Directive object ) The config tree to stringify arg1: $directive ( string ) The name of the directive to search for opt arg2: args ( string ) Optional args to the directive to filter for ret: $string ( string / ARRAY of HASH refs ) In LIST context, it returns all matching nodes. In SCALAR context, it returns only the first matching node. If called with only $directive value, this method returns all nodes from that directive. For example: @Alias = $conftree−>lookup('Alias');
returns all nodes for Alias directives. If called with an extra $args argument, it returns only nodes where both the directive and the args matched. For example: $VHost = $tree−>lookup('VirtualHost', '_default_:8000');
since: 2.0.00
nextGet the next directive node in the tree: $next_node = $node−>next();
obj: $node ( Apache2::Directive object ) ret: $next_node ( Apache2::Directive object ) Returns the next sibling of $node, undef if there is none since: 2.0.00
parentGet the parent node of this directive: $parent_node = $node−>parent();
obj: $node ( Apache2::Directive object ) ret: parent_node ( Apache2::Directive object ) Returns the parent of $node, undef if this node is the root node since: 2.0.00
See Alsomod_perl 2.0 documentation.
Copyrightmod_perl 2.0 and its core modules are copyrighted under The Apache Software License, Version 2.0.
AuthorsThe mod_perl development team and numerous contributors. 0
Johanes Gumabo
Data Size : 37,304 byte
man-Apache2::Directive.3pmBuild : 2024-12-05, 20:55 :
Visitor Screen : x
Visitor Counter ( page / site ) : 4 / 173,910
Visitor ID : :
Visitor IP : 3.145.79.214 :
Visitor Provider : AMAZON-02 :
Provider Position ( lat x lon ) : 39.962500 x -83.006100 : x
Provider Accuracy Radius ( km ) : 1000 :
Provider City : Columbus :
Provider Province : Ohio , : ,
Provider Country : United States :
Provider Continent : North America :
Visitor Recorder : Version :
Visitor Recorder : Library :
Online Linux Manual Page : Version : Online Linux Manual Page - Fedora.40 - march=x86-64 - mtune=generic - 24.12.05
Online Linux Manual Page : Library : lib_c - 24.10.03 - march=x86-64 - mtune=generic - Fedora.40
Online Linux Manual Page : Library : lib_m - 24.10.03 - march=x86-64 - mtune=generic - Fedora.40
Data Base : Version : Online Linux Manual Page Database - 24.04.13 - march=x86-64 - mtune=generic - fedora-38
Data Base : Library : lib_c - 23.02.07 - march=x86-64 - mtune=generic - fedora.36
Very long time ago, I have the best tutor, Wenzel Svojanovsky . If someone knows the email address of Wenzel Svojanovsky , please send an email to johanes_gumabo@yahoo.co.id .
If error, please print screen and send to johanes_gumabo@yahoo.co.id
Under development. Support me via PayPal.
ERROR : Need New Coding : (parse_manual_page_|249|Apache2::Directive.3pm|36/37|el══─{─══.|.el══─{─══. ds -- \|\(em\|
) (htmlprn|149|Apache2::Directive.3pm|36/37|.el══─{─══. ds -- — |.el══─{─══. ds -- \|\(em\|
) (parse_manual_page_|249|Apache2::Directive.3pm|43|br══─}─══|'br══─}─══
) (htmlprn|149|Apache2::Directive.3pm|43|'br══─}─══ |'br══─}─══
)