I've tried several variations using vars, double and single quotes, but have been unable to get it to parse anything from memory. It *does* work if I give it a file, but the example above doesn't seems to work -- which seems pretty basic.# Create a document from source $Document = PPI::Document->new(\'print "Hello World!\n"');
I'm wanting to use it for memory-based input and no files are involved, For example, I might want to parse the same line 2 different ways (maybe with a trailing semicolon, or w/o, or some other way).
I'm wondering what syntax is suppose to work -- I also pointed out that the documented example doesn't work in their issue database, but no response on that. So does anyone have any working examples? My basic framework (in a file called ppi_dump) looks like:
#!/usr/bin/perl use warnings; use strict; # use utf8; use open IN=>q(:utf8); use open OUT=>q(:utf8); use PPI; use PPI::Dumper; use P; P "parse: %s", $ARGV[0]; my $doc=PPI::Document->new($ARGV[0]); my $dumpr=PPI::Dumper->new($doc, qw(whitespace 0 comments 0)); # .my $toks = $dumpr->list; # for indirect access... $dumpr->print;
A working example should suffice to jumpstart this -- from the documentation, I would have thought a string would have worked for my "arg", like:
> ppi_dump 'print "Hello World!\n"' parse: print "Hello World!\n" Can't call method "list" on an undefined value at ./ppi_dump line 14.
FWIW, if I give it a filename, it shows the content of the file, parsed, but the parse from string is the issue.
Tnx...
In reply to PPI usage w/r/t documentation by perl-diddler
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |