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

TO DO

73       - Write unit tests for this package
74

SUPPORT

76       See the support section in the main module.
77

AUTHOR

79       Adam Kennedy <adamk@cpan.org>
80
82       Copyright 2001 - 2006 Adam Kennedy.
83
84       This program is free software; you can redistribute it and/or modify it
85       under the same terms as Perl itself.
86
87       The full text of the license can be found in the LICENSE file included
88       with this module.
89
90
91
92perl v5.8.8                       2006-09-23            PPI::Statement::Sub(3)
Impressum