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 the subroutine's prototype, or undef if the subroutine does not
40       define one. Note that when the sub has an empty prototype ("()") the
41       return is an empty string.
42
43   block
44       With its name and implementation shared with PPI::Statement::Scheduled,
45       the "block" method finds and returns the actual Structure object of the
46       code block for this subroutine.
47
48       Returns false if this is a forward declaration, or otherwise does not
49       have a code block.
50
51   forward
52       The "forward" method returns true if the subroutine declaration is a
53       forward declaration.
54
55       That is, it returns false if the subroutine has a code block, or true
56       if it does not.
57
58   reserved
59       The "reserved" method provides a convenience method for checking to see
60       if this is a special reserved subroutine. It does not check against any
61       particular list of reserved sub names, but just returns true if the
62       name is all uppercase, as defined in perlsub.
63
64       Note that in the case of BEGIN, CHECK, UNITCHECK, INIT and END, these
65       will be defined as PPI::Statement::Scheduled objects, not subroutines.
66
67       Returns true if it is a special reserved subroutine, or false if not.
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.28.0                      2017-06-22            PPI::Statement::Sub(3)
Impressum