-
-
02 Dec 2017 01:11:57 UTC
- Distribution: PPIx-Literal
- Module version: v0.1.0
- Source (raw)
- Browse (raw)
- Changes
- How to Contribute
- Issues
- Testers (877 / 0 / 24)
- Kwalitee
Bus factor: 1- 90.08% Coverage
- License: perl_5
- Perl: v5.10.0
- Activity
24 month- Tools
- Download (13.18KB)
- MetaCPAN Explorer
- Permissions
- Subscribe to distribution
- Permalinks
- This version
- Latest version
- Dependencies
- Carp
- strict
- warnings
- Reverse dependencies
- CPAN Testers List
- Dependency graph
NAME
PPIx::Literal - Convert PPI nodes into literal values
VERSION
version 0.1.0
SYNOPSIS
use PPI; use PPIx::Literal; my $doc = PPI::Document->new( \q{(1, "one", 'two')} ); my @values = PPIx::Literal->convert($doc); # (1, "one", "two") my $doc = PPI::Document->new( \q{ [ 3.14, 'exp', { one => 1 } ] } ); my @values = PPIx::Literal->convert($doc); # [3.14, "exp", { one => 1 }] my $doc = PPI::Document->new( \q{use zim 'Carp' => qw(carp croak)} ); my ($use) = $doc->children; my @values = PPIx::Literal->convert( $use->arguments ); # ("Carp", "carp", "croak")
DESCRIPTION
This code is alpha quality. It is an early release. Interface may change. There may be serious bugs.
This module implements the conversion of a small subset of Perl into their literal values. The perl code to be converted is represented as a list of PPI nodes.
The conversion works for pieces which gets built from literal tokens and which don't require any kind of compilation.
Some examples are:
42 # number "a + b" # plain strings qw(a b c) # quoted words [] # anon array refs { -version => '0.3.2' }, # anon hash refs (2, 3, 4) # literal lists
The result of the conversion is a list of Perl data structures which contain plain scalars and "unknowns" as leafs. The "unknowns" are used to represent PPI nodes which can't be converted to literals.
METHODS
PPIx::Literal implements the following methods.
convert
@values = PPIx::Literal->convert(@nodes);
Convert
@nodes
into their literal values or into "unknowns".SEE ALSO
AUTHOR
Adriano Ferreira <ferreira@cpan.org>
COPYRIGHT AND LICENSE
This software is copyright (c) 2017 by Adriano Ferreira.
This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.
Module Install Instructions
To install PPIx::Literal, copy and paste the appropriate command in to your terminal.
cpanm PPIx::Literal
perl -MCPAN -e shell install PPIx::Literal
For more information on module installation, please visit the detailed CPAN module installation guide.