"PPI::Statement::Include" has a number of methods in addition to the standard PPI::Statement, PPI::Node
and PPI::Element methods.
type
The "type" method returns the general type of statement ('use', 'no' or 'require').
Returns the type as a string, or "undef" if the type cannot be detected.
module
The "module" method returns the module name specified in any include statement. This "includes" pragma
names, because pragma are implemented as modules. (And lets face it, the definition of a pragma can be
fuzzy at the best of times in any case)
This covers all of these...
use strict;
use My::Module;
no strict;
require My::Module;
...but does not cover any of these...
use 5.006;
require 5.005;
require "explicit/file/name.pl";
Returns the module name as a string, or "undef" if the include does not specify a module name.
module_version
The "module_version" method returns the minimum version of the module required by the statement, if there
is one.
pragma
The "pragma" method checks for an include statement's use as a pragma, and returns it if so.
Or at least, it claims to. In practice it's a lot harder to say exactly what is or isn't a pragma,
because the definition is fuzzy.
The "intent" of a pragma is to modify the way in which the parser works. This is done though the use of
modules that do various types of internals magic.
For now, PPI assumes that any "module name" that is only a set of lowercase letters (and perhaps numbers,
like "use utf8;"). This behaviour is expected to change, most likely to something that knows the specific
names of the various "pragmas".
Returns the name of the pragma, or false ('') if the include is not a pragma.
version
The "version" method checks for an include statement that introduces a dependency on the version of
"perl" the code is compatible with.
This covers two specific statements.
use 5.006;
require 5.006;
Currently the version is returned as a string, although in future the version may be returned as a
version object. If you want a numeric representation, use version_literal(). Returns false if the
statement is not a version dependency.
version_literal
The "version_literal" method has the same behavior as version(), but the version is returned as a numeric
literal. Returns false if the statement is not a version dependency.
arguments
The "arguments" method gives you the rest of the statement after the module/pragma and module version,
i.e. the stuff that will be used to construct what gets passed to the module's import() subroutine. This
does include the comma, etc. operators, but doesn't include non-significant direct children or any final
semicolon.
feature_mods
# `use feature 'signatures';`
my %mods = $include->feature_mods;
# { signatures => "perl" }
# `use 5.036;`
my %mods = $include->feature_mods;
# { signatures => "perl" }
Returns a hashref of features identified as enabled by the include, or undef if the include does not
enable features. The value for each feature indicates the provider of the feature.