1PPIx::Utilities::Node(3U)ser Contributed Perl DocumentatiPoPnIx::Utilities::Node(3)
2
3
4

NAME

6       PPIx::Utilities::Node - Extensions to PPI::Node.
7

VERSION

9       This document describes PPIx::Utilities::Node version 1.1.0.
10

SYNOPSIS

12           use PPIx::Utilities::Node qw< split_ppi_node_by_namespace >;
13
14           my $dom = PPI::Document->new("...");
15
16           while (
17               my ($namespace, $sub_doms) = each split_ppi_node_by_namespace($dom)
18           ) {
19               foreach my $sub_dom ( @{$sub_doms} ) {
20                   ...
21               }
22           }
23

DESCRIPTION

25       This is a collection of functions for dealing with PPI::Nodes.
26

INTERFACE

28       Nothing is exported by default.
29
30   split_ppi_node_by_namespace($node)
31       Returns the sub-trees for each namespace in the node as a reference to
32       a hash of references to arrays of PPI::Nodes.  Say we've got the
33       following code:
34
35           #!perl
36
37           my $x = blah();
38
39           package Foo;
40
41           my $y = blah_blah();
42
43           {
44               say 'Whee!';
45
46               package Bar;
47
48               something();
49           }
50
51           thingy();
52
53           package Baz;
54
55           da_da_da();
56
57           package Foo;
58
59           foreach ( blrfl() ) {
60               ...
61           }
62
63       Calling this function on a PPI::Document for the above returns a value
64       that looks like this, using multi-line string literals for the actual
65       code parts instead of PPI trees to make this easier to read:
66
67           {
68               main    => [
69                   q<
70                       #!perl
71
72                       my $x = blah();
73                   >,
74               ],
75               Foo     => [
76                   q<
77                       package Foo;
78
79                       my $y = blah_blah();
80
81                       {
82                           say 'Whee!';
83
84                       }
85
86                       thingy();
87                   >,
88                   q<
89                       package Foo;
90
91                       foreach ( blrfl() ) {
92                           ...
93                       }
94                   >,
95               ],
96               Bar     => [
97                   q<
98                       package Bar;
99
100                       something();
101                   >,
102               ],
103               Baz     => [
104                   q<
105                       package Baz;
106
107                       da_da_da();
108                   >,
109               ],
110           }
111
112       Note that the return value contains copies of the original nodes, and
113       not the original nodes themselves due to the need to handle namespaces
114       that are not file-scoped.  (Notice how the first element for "Foo"
115       above differs from the original code.)
116

BUGS AND LIMITATIONS

118       Please report any bugs or feature requests to
119       "bug-ppix-utilities@rt.cpan.org", or through the web interface at
120       <http://rt.cpan.org>.
121

AUTHOR

123       Elliot Shank  "<perl@galumph.com>"
124
126       Copyright (c)2009-2010, Elliot Shank "<perl@galumph.com>".
127
128       This program is free software; you can redistribute it and/or modify it
129       under the same terms as Perl itself.  The full text of this license can
130       be found in the LICENSE file included with this module.
131
132
133
134perl v5.32.0                      2020-07-28          PPIx::Utilities::Node(3)
Impressum