1PPI::Statement::CompounUds(e3r)Contributed Perl DocumentPaPtIi:o:nStatement::Compound(3)
2
3
4
6 PPI::Statement::Compound - Describes all compound statements
7
9 # A compound if statement
10 if ( foo ) {
11 bar();
12 } else {
13 baz();
14 }
15
16 # A compound loop statement
17 foreach ( @list ) {
18 bar($_);
19 }
20
22 PPI::Statement::Compound
23 isa PPI::Statement
24 isa PPI::Node
25 isa PPI::Element
26
28 "PPI::Statement::Compound" objects are used to describe all current
29 forms of compound statements, as described in perlsyn.
30
31 This covers blocks using "if", "unless", "for", "foreach", "while", and
32 "continue". Please note this does not cover "simple" statements with
33 trailing conditions. Please note also that "do" is also not part of a
34 compound statement.
35
36 # This is NOT a compound statement
37 my $foo = 1 if $condition;
38
39 # This is also not a compound statement
40 do { ... } until $condition;
41
43 "PPI::Statement::Compound" has a number of methods in addition to the
44 standard PPI::Statement, PPI::Node and PPI::Element methods.
45
46 type
47 The "type" method returns the syntactic type of the compound statement.
48
49 There are four basic compound statement types.
50
51 The 'if' type includes all variations of the if and unless statements,
52 including any 'elsif' or 'else' parts of the compound statement.
53
54 The 'while' type describes the standard while and until statements, but
55 again does not describes simple statements with a trailing while.
56
57 The 'for' type covers the C-style for loops, regardless of whether they
58 were declared using 'for' or 'foreach'.
59
60 The 'foreach' type covers loops that iterate over collections,
61 regardless of whether they were declared using 'for' or 'foreach'.
62
63 All of the compounds are a variation on one of these four.
64
65 Returns the simple string 'if', 'for', 'foreach' or 'while', or "undef"
66 if the type cannot be determined.
67
69 - Write unit tests for this package
70
72 See the support section in the main module.
73
75 Adam Kennedy <adamk@cpan.org>
76
78 Copyright 2001 - 2011 Adam Kennedy.
79
80 This program is free software; you can redistribute it and/or modify it
81 under the same terms as Perl itself.
82
83 The full text of the license can be found in the LICENSE file included
84 with this module.
85
86
87
88perl v5.12.3 2011-02-26 PPI::Statement::Compound(3)