PPI::St...ompound(3)

✨ NAME ✨

okay so bestie, this page is PPI::Statement::Compound β€” it's the module that describes all compound statements πŸ’… (and yes the manpage name got truncated to PPI::St...ompound(3) which is giving ✨mystery✨ but it's fr fr PPI::Statement::Compound from User Contributed Perl Documentation, iykyk).


🌸 SYNOPSIS 🌸

# A compound if statement
if ( foo ) {
    bar();
} else {
    baz();
}

# A compound loop statement
foreach ( @list ) {
    bar($_);
}

like... look at her go 🫢 she's compounding. iconic behavior.


πŸ¦‹ INHERITANCE πŸ¦‹

PPI::Statement::Compound
isa PPI::Statement
    isa PPI::Node
        isa PPI::Element

the family tree ate, no cap 🌈 she's a PPI::Statement, which is a PPI::Node, which is a PPI::Element. periodt.


πŸ’– DESCRIPTION πŸ’–

PPI::Statement::Compound objects are the little narrators that describe all current forms of compound statements, exactly as laid out in perlsyn.

so what's covered? blocks using if, unless, for, foreach, while, and continue. that's the squad πŸ‘‘

but bestie, listen, two things are NOT covered:

  • "simple" statements with trailing conditions β€” nope, not her.
  • do is also not part of a compound statement. like, at all. πŸ™ˆ

watch:

# This is NOT a compound statement
my $foo = 1 if $condition;

# This is also not a compound statement
do { ... } until $condition;

see how they look like they're in the group chat but they never actually joined?? πŸ’€ not compound. moving on.


πŸŽ€ METHODS πŸŽ€

PPI::Statement::Compound has a bunch of methods on top of the standard PPI::Statement, PPI::Node and PPI::Element methods. she's doing overtime πŸ’…

⭐ type ⭐

the type method returns the syntactic type of the compound statement.

there are four basic compound statement types:

  • the if type includes all variations of the if and unless statements β€” including any elsif or else parts of the compound statement. the whole polycule, together 🫢
  • the while type describes the standard while and until statements β€” but again, does not describe simple statements with a trailing while. (we said what we said.)
  • the for type covers the C-style for loops, regardless of whether they were declared using for or foreach. she doesn't care about your label, she cares about your vibe.
  • the foreach type covers loops that iterate over collections, regardless of whether they were declared using for or foreach. same energy, opposite direction.

and every single compound out there is just a variation on one of these four. that's the whole taxonomy, slay.

returns the simple string 'if', 'for', 'foreach' or 'while' β€” or undef if the type cannot be determined 😭 (she's mysterious like that sometimes).


πŸ“ TO DO πŸ“

  • Write unit tests for this package

(one item. one. it's been sitting there. someone please πŸ₯Ί)


🫢 SUPPORT 🫢

See the support section in the main module.


πŸ‘‘ AUTHOR πŸ‘‘

Adam Kennedy <adamk@cpan.org>


Copyright 2001 - 2011 Adam Kennedy.

This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.

The full text of the license can be found in the LICENSE file included with this module.


ok so like the tiny fine print: this is perl v5.42.0, dated 2026-01-17, and the page lives at PPI::St...ompound(3). thanks for coming to my ted talk, mwah πŸ’‹βœ¨ go write some unit tests bestie πŸ’–
πŸ“¦ where this page comes from