1PPI::Statement::IncludeU(s3e)r Contributed Perl DocumentaPtPiIo:n:Statement::Include(3)
2
3
4

NAME

6       PPI::Statement::Include - Statements that include other code
7

SYNOPSIS

9         # The following are all includes
10         use 5.006;
11         use strict;
12         use My::Module;
13         use constant FOO => 'Foo';
14         require Foo::Bar;
15         require "Foo/Bar.pm";
16         require $foo if 1;
17         no strict 'refs';
18

INHERITANCE

20         PPI::Statement::Include
21         isa PPI::Statement
22             isa PPI::Node
23                 isa PPI::Element
24

DESCRIPTION

26       Despite its name, the "PPI::Statement::Include" class covers a number
27       of different types of statement that cover all statements starting with
28       "use", "no" and "require".
29
30       But basically, they cover three situations.
31
32       Firstly, a dependency on a particular version of perl (for which the
33       "version" method returns true), a pragma (for which the "pragma" method
34       returns true), or the loading (and unloading via no) of modules.
35

METHODS

37       "PPI::Statement::Include" has a number of methods in addition to the
38       standard PPI::Statement, PPI::Node and PPI::Element methods.
39
40   type
41       The "type" method returns the general type of statement ('use', 'no' or
42       'require').
43
44       Returns the type as a string, or "undef" if the type cannot be
45       detected.
46
47   module
48       The "module" method returns the module name specified in any include
49       statement. This "includes" pragma names, because pragma are implemented
50       as modules. (And lets face it, the definition of a pragma can be fuzzy
51       at the best of times in any case)
52
53       This covers all of these...
54
55         use strict;
56         use My::Module;
57         no strict;
58         require My::Module;
59
60       ...but does not cover any of these...
61
62         use 5.006;
63         require 5.005;
64         require "explicit/file/name.pl";
65
66       Returns the module name as a string, or "undef" if the include does not
67       specify a module name.
68
69   module_version
70       The "module_version" method returns the minimum version of the module
71       required by the statement, if there is one.
72
73   pragma
74       The "pragma" method checks for an include statement's use as a pragma,
75       and returns it if so.
76
77       Or at least, it claims to. In practice it's a lot harder to say exactly
78       what is or isn't a pragma, because the definition is fuzzy.
79
80       The "intent" of a pragma is to modify the way in which the parser
81       works.  This is done though the use of modules that do various types of
82       internals magic.
83
84       For now, PPI assumes that any "module name" that is only a set of
85       lowercase letters (and perhaps numbers, like "use utf8;"). This
86       behaviour is expected to change, most likely to something that knows
87       the specific names of the various "pragmas".
88
89       Returns the name of the pragma, or false ('') if the include is not a
90       pragma.
91
92   version
93       The "version" method checks for an include statement that introduces a
94       dependency on the version of "perl" the code is compatible with.
95
96       This covers two specific statements.
97
98         use 5.006;
99         require 5.006;
100
101       Currently the version is returned as a string, although in future the
102       version may be returned as a version object.  If you want a numeric
103       representation, use "version_literal()".  Returns false if the
104       statement is not a version dependency.
105
106   version_literal
107       The "version_literal" method has the same behavior as "version()", but
108       the version is returned as a numeric literal.  Returns false if the
109       statement is not a version dependency.
110
111   arguments
112       The "arguments" method gives you the rest of the statement after the
113       module/pragma and module version, i.e. the stuff that will be used to
114       construct what gets passed to the module's "import()" subroutine.  This
115       does include the comma, etc. operators, but doesn't include non-
116       significant direct children or any final semicolon.
117

TO DO

119       - Write specific unit tests for this package
120

SUPPORT

122       See the support section in the main module.
123

AUTHOR

125       Adam Kennedy <adamk@cpan.org>
126
128       Copyright 2001 - 2011 Adam Kennedy.
129
130       This program is free software; you can redistribute it and/or modify it
131       under the same terms as Perl itself.
132
133       The full text of the license can be found in the LICENSE file included
134       with this module.
135
136
137
138perl v5.28.0                      2017-06-22        PPI::Statement::Include(3)
Impressum