in reply to PPI usage w/r/t documentation
Hello perl-diddler,
I have no experience with the PPI modules, but I can get (a slightly simplified version of) your code to work by adding a backslash before $ARGV[0] in the call to PPI::Document->new:
#! perl use warnings; use strict; use PPI; use PPI::Dumper; printf "parse: >%s<\n", $ARGV[0]; my $doc = PPI::Document->new(\$ARGV[0]) or die "PPI::Document->new failed: $!"; my $dumpr = PPI::Dumper->new($doc) or die "PPI::Dumper->new failed: $!"; $dumpr->print;
Output:
14:25 >perl 1688_SoPW.pl "print qq[Hello world!\n];" parse: >print qq[Hello world!\n];< PPI::Document PPI::Statement PPI::Token::Word 'print' PPI::Token::Whitespace ' ' PPI::Token::Quote::Interpolate 'qq[Hello world!\n]' PPI::Token::Structure ';' 14:25 >
Note that it’s good practice to die on failure: in this case, it identifies the call to PPI::Document->new as the location of the problem.
Also note that I use double quotes on the command line because I’m on Windows.
Hope that helps,
| Athanasius <°(((>< contra mundum | Iustus alius egestas vitae, eros Piratica, |
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: PPI usage w/r/t documentation
by perl-diddler (Chaplain) on Aug 28, 2016 at 04:39 UTC |