PPI::St...ariable(3)

πŸ’– NAME πŸ’–

okay bestie, meet PPI::Statement::Variable β€” it's the whole variable declaration statements vibe, living its life in section 3 of the manual (PPI::Statement::Variable(3), iykyk). ✨


🌸 SYNOPSIS 🌸

like, every single one of these bad boys down here? a variable declaration. all of them. no cap:

# All of the following are variable declarations
my $foo = 1;
my ($foo, $bar) = (1, 2);
our $foo = 1;
local $foo;
local $foo = 1;
LABEL: my $foo = 1;

πŸ¦‹ INHERITANCE πŸ¦‹

the family tree is giving generational excellence, fr fr:

PPI::Statement::Variable
isa PPI::Statement::Expression
    isa PPI::Statement
        isa PPI::Node
            isa PPI::Element

πŸ’… DESCRIPTION πŸ’…

so the main intent of the PPI::Statement::Variable class is to describe the simple little statements that explicitly declare brand-new local or global variables. that's its whole job, and it eats. πŸ‘‘

but β€” and this is important, don't skip it β€” that does not make this class the exclusive only place where variables get defined. nope. later on you should expect that the variables method is gonna migrate deeper down the tree, over to either PPI::Statement or PPI::Node, so it can recognise that fact. but for now? it stays here. it's staying. periodt. πŸ’€


✨ METHODS ✨

πŸŽ€ type

the type method checks the declaration type of the statement and hands it right back to you. it'll be one of 'my', 'local', 'our', or 'state'. iconic lineup honestly.

it returns a string of the type β€” or undef if the type can't be detected, which is probably a bug btw. πŸ™ˆ

πŸ“ variables

just like several other PDOM Element types that can declare variables, the variables method returns a list of the canonical forms of the variables defined by the statement.

it returns a list of the canonical string forms of variables β€” or the null list if it can't find any variables at all. πŸ’«

🧚 symbols

returns a list of the variables defined by the statement, as PPI::Token::Symbols. cute, literal, slay.


πŸ’œ TO DO πŸ’œ

  • Write unit tests for this
not me calling out the missing tests… bestie the tests are literally right there waiting to be written 😭 someone please give this module its moment

🫢 SUPPORT 🫢

See the support section in the main module. go look, it's right there, i promise. πŸ’–


🌈 AUTHOR 🌈

Adam Kennedy <adamk@cpan.org> β€” the icon, the legend, the main character. πŸ‘‘


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. read it bestie, it's giving legal realness. πŸ“œ


and that's a wrap on the PPI::Statement::Variable page πŸ’… β€” this gem shipped as part of User Contributed Perl Documentation for perl v5.42.0, dated 2026-01-17. go forth and parse those declarations, you gorgeous nerd. mwah. πŸ’–βœ¨πŸŽ€

πŸ“¦ where this page comes from