PPIx::DocumentName::Result3pm
Full result set for ppix::documentname
Usage
use PPIx::DocumentName 1.00 -api => 1;my $result = PPIx::DocumentName->extract( $ppi_document );# say the "name" of the documentsay $result->name;# the result object can also be stringified into the name found:say "$result";# get the full PPI::Document object for the entire documentmy $ppi = $result->document;# get the node where we found the name# (usually a PPI::Statement::Package or PPI::Token::Comment)my $node = $result->node;# get the location where we found the namemy $location = $result->node->location;
Version
version 1.01
Overview
This class represents the results from PPIx::DocumentName when running under its new "-api => 1" API.
Methods
name
my $name = $result->name;
Returns the name that was found in the document.
to_string
my $str = $result->to_string;my $str = "$result";
Convert this object to a string. This is the same as the "name" method. This method will also be invoked if stringified inside a double quoted string.
document
my $ppi = $result->document;
Returns the PPI::Document of the document.
node
my $node = $result->node;
Returns the PPI::Node where the name was found. This will usually be either PPI::Statement::Package or PPI::Token::Comment, although other types could be used in the future.
Caveats
For "node" to be useful, the "document" object needs to remain in scope, this is the main reason the result object keeps it around, so if you want to use the "node" to get the location information, make sure that you do not throw away the result object.
Bad:
my $node = PPIx::DocumentName->extract( $ppi_document )->node;my $location = $node->location; # undef
Fine:
my $result = PPIx::DocumentName->extract( $ppi_document );my $node = $result->node;my $location = $node->location; # ok
Copyright and license
This software is copyright (c) 2015-2021 by Kent Fredric <[email protected]>.
This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.
Releases
Unchanged in 2 releases since Debian 12 (Bookworm).