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
42       The "type" method returns the general type of statement ('use', 'no' or
43       'require').
44
45       Returns the type as a string, or "undef" if the type cannot be
46       detected.
47
48       module
49
50       The "module" method returns the module name specified in any include
51       statement. This "includes" pragma names, because pragma are implemented
52       as modules. (And lets face it, the definition of a pragma can be fuzzy
53       at the best of times in any case)
54
55       This covers all of these...
56
57         use strict;
58         use My::Module;
59         no strict;
60         require My::Module;
61
62       ...but does not cover any of these...
63
64         use 5.006;
65         require 5.005;
66         require "explicit/file/name.pl";
67
68       Returns the module name as a string, or "undef" if the include does not
69       specify a module name.
70
71       pragma
72
73       The "pragma" method checks for an include statement's use as a pragma,
74       and returns it if so.
75
76       Or at least, it claims to. In practice it's a lot harder to say exactly
77       what is or isn't a pragma, because the definition is fuzzy.
78
79       The "intent" of a pragma is to modify the way in which the parser
80       works.  This is done though the use of modules that do various types of
81       internals magic.
82
83       For now, PPI assumes that any "module name" that is only a set of low‐
84       ercase letters. This behaviour is expected to change, most likely to
85       something that knows the specific names of the various "pragmas".
86
87       Returns the name of the pragma, or false ('') if the include is not a
88       pragma.
89
90       The "version" method checks for an include statement that introduces a
91       dependency on the version of "perl" the code is compatible with.
92
93       This covers two specific statements.
94
95         use 5.006;
96         require 5.006;
97
98       Currently the version is returned as a string, although in future the
99       version may be returned as a numeric literal, or more likely as a ver‐
100       sion object. Returns false if the statement is not a version depen‐
101       dency.
102

TO DO

104       - Write specific unit tests for this package
105

SUPPORT

107       See the support section in the main module.
108

AUTHOR

110       Adam Kennedy <adamk@cpan.org>
111
113       Copyright 2001 - 2006 Adam Kennedy.
114
115       This program is free software; you can redistribute it and/or modify it
116       under the same terms as Perl itself.
117
118       The full text of the license can be found in the LICENSE file included
119       with this module.
120
121
122
123perl v5.8.8                       2006-09-23        PPI::Statement::Include(3)
Impressum