1PPI::Statement::PackageU(s3e)r Contributed Perl DocumentaPtPiIo:n:Statement::Package(3)
2
3
4

NAME

6       PPI::Statement::Package - A package statement
7

INHERITANCE

9         PPI::Statement::Package
10         isa PPI::Statement
11             isa PPI::Node
12                 isa PPI::Element
13

DESCRIPTION

15       Most PPI::Statement subclasses are assigned based on the value of the
16       first token or word found in the statement. When PPI encounters a
17       statement starting with 'package', it converts it to a
18       "PPI::Statement::Package" object.
19
20       When working with package statements, please remember that packages
21       only exist within their scope, and proper support for scoping has yet
22       to be completed in PPI.
23
24       However, if the immediate parent of the package statement is the top
25       level PPI::Document object, then it can be considered to define
26       everything found until the next top-level "file scoped" package
27       statement.
28
29       A file may, however, contain nested temporary package, in which case
30       you are mostly on your own :)
31

METHODS

33       "PPI::Statement::Package" has a number of methods in addition to the
34       standard PPI::Statement, PPI::Node and PPI::Element methods.
35
36   namespace
37       Most package declarations are simple, and just look something like
38
39         package Foo::Bar;
40
41       The "namespace" method returns the name of the declared package, in the
42       above case 'Foo::Bar'. It returns this exactly as written and does not
43       attempt to clean up or resolve things like ::Foo to main::Foo.
44
45       If the package statement is done any different way, it returns false.
46
47   version
48       Some package declarations may include a version:
49
50         package Foo::Bar 1.23;
51         package Baz v1.23;
52
53       The "version" method returns the stringified version as seen in the
54       document (if any), otherwise the empty string.
55
56   file_scoped
57       Regardless of whether it is named or not, the "file_scoped" method will
58       test to see if the package declaration is a top level "file scoped"
59       statement or not, based on its location.
60
61       In general, returns true if it is a "file scoped" package declaration
62       with an immediate parent of the top level Document, or false if not.
63
64       Note that if the PPI DOM tree does not have a PPI::Document object at
65       as the root element, this will return false. Likewise, it will also
66       return false if the root element is a PPI::Document::Fragment, as a
67       fragment of a file does not represent a scope.
68

SUPPORT

70       See the support section in the main module.
71

AUTHOR

73       Adam Kennedy <adamk@cpan.org>
74
76       Copyright 2001 - 2011 Adam Kennedy.
77
78       This program is free software; you can redistribute it and/or modify it
79       under the same terms as Perl itself.
80
81       The full text of the license can be found in the LICENSE file included
82       with this module.
83
84
85
86perl v5.36.0                      2023-01-20        PPI::Statement::Package(3)
Impressum