1PPI::Statement::PackageU(s3e)r Contributed Perl DocumentaPtPiIo:n:Statement::Package(3)
2
3
4
6 PPI::Statement::Package - A package statement
7
9 PPI::Statement::Package
10 isa PPI::Statement
11 isa PPI::Node
12 isa PPI::Element
13
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
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 file_scoped
48 Regardless of whether it is named or not, the "file_scoped" method will
49 test to see if the package declaration is a top level "file scoped"
50 statement or not, based on its location.
51
52 In general, returns true if it is a "file scoped" package declaration
53 with an immediate parent of the top level Document, or false if not.
54
55 Note that if the PPI DOM tree does not have a PPI::Document object at
56 as the root element, this will return false. Likewise, it will also
57 return false if the root element is a PPI::Document::Fragment, as a
58 fragment of a file does not represent a scope.
59
61 See the support section in the main module.
62
64 Adam Kennedy <adamk@cpan.org>
65
67 Copyright 2001 - 2011 Adam Kennedy.
68
69 This program is free software; you can redistribute it and/or modify it
70 under the same terms as Perl itself.
71
72 The full text of the license can be found in the LICENSE file included
73 with this module.
74
75
76
77perl v5.16.3 2011-02-26 PPI::Statement::Package(3)