add use strict; use warnings to modules, just to be sure
[p5sagit/Devel-REPL.git] / lib / Devel / REPL / Plugin / PPI.pm
CommitLineData
c5bf3ed2 1#!/usr/bin/perl
2
1716b200 3use strict;
4use warnings;
c5bf3ed2 5package Devel::REPL::Plugin::PPI;
6use Devel::REPL::Plugin;
7
8use PPI;
9use PPI::Dumper;
10
aa8b7647 11use namespace::autoclean;
c5bf3ed2 12
3a400715 13sub BEFORE_PLUGIN {
14 my $self = shift;
15 $self->load_plugin('Turtles');
16}
c5bf3ed2 17
18sub expr_command_ppi {
19 my ( $self, $eval, $code ) = @_;
20
21 my $document = PPI::Document->new(\$code);
22 my $dumper = PPI::Dumper->new($document);
23 return $dumper->string;
24}
25
26__PACKAGE__
27
28__END__
29
30=pod
31
32=head1 NAME
33
34Devel::REPL::Plugin::PPI - PPI dumping of Perl code
35
36=head1 SYNOPSIS
37
38 repl> #ppi Devel::REPL
39 PPI::Document
40 PPI::Statement
41 PPI::Token::Word 'Devel::REPL'
42
43 repl> #ppi {
44 > warn $];
45 > }
46 PPI::Document
47 PPI::Statement::Compound
48 PPI::Structure::Block { ... }
49 PPI::Token::Whitespace '\n'
50 PPI::Statement
51 PPI::Token::Word 'warn'
52 PPI::Token::Whitespace ' '
53 PPI::Token::Magic '$]'
54 PPI::Token::Structure ';'
55 PPI::Token::Whitespace '\n'
56
57=head1 DESCRIPTION
58
59This plugin provides a C<ppi> command that uses L<PPI::Dumper> to dump
60L<PPI>-parsed Perl documents.
61
62The code is not actually executed, which means that when used with
63L<Deve::REPL::Plugin::OutputCache> there is no new value in C<_>.
64
65=head1 AUTHOR
66
67Shawn M Moore E<lt>sartak@gmail.comE<gt>
68
69=cut
70
71