[Wellington-pm] PPI

Kent Fredric kentfredric at gmail.com
Sun Mar 19 07:21:09 PDT 2017


On 15 March 2017 at 11:05, Steve Piner <Steve.Piner at signify.co.nz> wrote:

> As mentioned in the meeting, PPI might be useful for Perl-ish syntax
> checking, without executing Perl. If you use syntax-warping modules
> however, PPI probably won't be sufficient.


Just be careful. PPI can do magical things :)

Like .... Accidentally parse XML as if it was perl.

perl -MPPI -MData::Dump=pp -e "my \$ppi =
PPI::Document->new(\\'<list></list>'); print pp \$ppi "

bless({
  children  => [
                 bless({
                   children => [
                     bless({ content => "<" }, "PPI::Token::Operator"),
                     bless({ content => "list" }, "PPI::Token::Word"),
                     bless({ content => ">" }, "PPI::Token::Operator"),
                     bless({ content => "<" }, "PPI::Token::Operator"),
                     bless({
                       _sections => 1,
                       braced    => 0,
                       content   => "/list>",
                       modifiers => {},
                       operator  => undef,
                       sections  => [{ position => 1, size => 5, type =>
"//" }],
                       separator => "/",
                     }, "PPI::Token::Regexp::Match"),
                   ],
                 }, "PPI::Statement"),
               ],
  readonly  => "",
  tab_width => 1,
}, "PPI::Document")

How I found out: https://rt.cpan.org/Ticket/Display.html?id=120578

--
Kent

*KENTNL* - https://metacpan.org/author/KENTNL
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.pm.org/pipermail/wellington-pm/attachments/20170320/555023d8/attachment.html>


More information about the Wellington-pm mailing list