ba0cea3c4e17bf94e85aa2ea8778e8f2bd52e7a7
[p5sagit/Devel-REPL.git] / lib / Devel / REPL / Plugin / Peek.pm
1 use strict;
2 use warnings;
3 package Devel::REPL::Plugin::Peek;
4
5 our $VERSION = '1.003027';
6
7 use Devel::REPL::Plugin;
8 use Devel::Peek qw(Dump);
9 use namespace::autoclean;
10
11 sub BEFORE_PLUGIN {
12     my $self = shift;
13     $self->load_plugin('Turtles');
14 }
15
16 sub expr_command_peek {
17   my ( $self, $eval, $code ) = @_;
18
19   my @res = $self->eval($code);
20
21   if ( $self->is_error(@res) ) {
22     return $self->format(@res);
23   } else {
24     # can't override output properly
25     # FIXME do some dup wizardry
26     Dump(@res);
27     return ""; # this is a hack to print nothing after Dump has already printed. PLZ TO FIX KTHX!
28   }
29 }
30
31 __PACKAGE__
32
33 __END__
34
35 =pod
36
37 =head1 NAME
38
39 Devel::REPL::Plugin::Peek - L<Devel::Peek> plugin for L<Devel::REPL>.
40
41 =head1 SYNOPSIS
42
43   repl> #peek "foo"
44   SV = PV(0xb3dba0) at 0xb4abc0
45     REFCNT = 1
46     FLAGS = (POK,READONLY,pPOK)
47     PV = 0x12bcf70 "foo"\0
48     CUR = 3
49     LEN = 4
50
51 =head1 DESCRIPTION
52
53 This L<Devel::REPL::Plugin> adds a C<peek> command that calls
54 L<Devel::Peek/Dump> instead of the normal printing.
55
56 =head1 SEE ALSO
57
58 L<Devel::REPL>, L<Devel::Peek>
59
60 =head1 AUTHOR
61
62 Yuval Kogman E<lt>nothingmuch@woobling.orgE<gt>
63
64 =cut