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