1PPI::Statement::Sub(3)User Contributed Perl DocumentationPPI::Statement::Sub(3)
2
3
4

NAME

6       PPI::Statement::Sub - Subroutine declaration
7

INHERITANCE

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

DESCRIPTION

15       Except for the special BEGIN, CHECK, UNITCHECK, INIT, and END
16       subroutines (which are part of PPI::Statement::Scheduled) all
17       subroutine declarations are lexed as a PPI::Statement::Sub object.
18
19       Primarily, this means all of the various "sub foo {}" statements, but
20       also forward declarations such as "sub foo;" or "sub foo($);". It does
21       not include anonymous subroutines, as these are merely part of a normal
22       statement.
23

METHODS

25       "PPI::Statement::Sub" has a number of methods in addition to the
26       standard PPI::Statement, PPI::Node and PPI::Element methods.
27
28   name
29       The "name" method returns the name of the subroutine being declared.
30
31       In some rare cases such as a naked "sub" at the end of the file, this
32       may return false.
33
34   prototype
35       If it has one, the "prototype" method returns the subroutine's
36       prototype.  It is returned in the same format as "prototype" in
37       PPI::Token::Prototype, cleaned and removed from its brackets.
38
39       Returns false if the subroutine does not define a prototype
40
41   block
42       With its name and implementation shared with PPI::Statement::Scheduled,
43       the "block" method finds and returns the actual Structure object of the
44       code block for this subroutine.
45
46       Returns false if this is a forward declaration, or otherwise does not
47       have a code block.
48
49   forward
50       The "forward" method returns true if the subroutine declaration is a
51       forward declaration.
52
53       That is, it returns false if the subroutine has a code block, or true
54       if it does not.
55
56   reserved
57       The "reserved" method provides a convenience method for checking to see
58       if this is a special reserved subroutine. It does not check against any
59       particular list of reserved sub names, but just returns true if the
60       name is all uppercase, as defined in perlsub.
61
62       Note that in the case of BEGIN, CHECK, UNITCHECK, INIT and END, these
63       will be defined as PPI::Statement::Scheduled objects, not subroutines.
64
65       Returns true if it is a special reserved subroutine, or false if not.
66

TO DO

68       - Write unit tests for this package
69

SUPPORT

71       See the support section in the main module.
72

AUTHOR

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