Build all packages removed dependencies of libtest-exception-perl libtest-warn-perl...
[dh-make-perl] / dev / i386 / libperl-critic-perl / libperl-critic-perl-1.088 / tools / ppidump
1 #!/usr/bin/env perl
2
3 use strict;
4 use warnings;
5
6 use PPI::Document;
7 use PPI::Dumper;
8
9 our $VERSION = '1.088';
10
11 my $whitespace = $ARGV[0] && $ARGV[0] eq '-w' ? shift : 0;
12 my $code = $ARGV[0] ? (-f $ARGV[0] ? shift : \shift) : \join q{}, <STDIN>;
13 my $doc  = PPI::Document->new( $code )
14     or die 'Could not parse code: ', PPI::Document::errstr(), "\n";
15 my $dump = PPI::Dumper->new( $doc, whitespace => $whitespace );
16 $dump->print();
17
18 __END__
19
20 #-----------------------------------------------------------------------------
21
22 =pod
23
24 =head1 NAME
25
26 ppidump - Dump Perl code as PPI structure.
27
28 =head1 SYNOPSIS
29
30   ppidump                     #Read from STDIN
31   ppidump MyModule.pm         #Read code from file
32   ppidump 'my $foo = $bar;'   #Read code as from string
33   ppidump -w 'foo( );'        #Show whitespace tokens
34
35 =head1 DESCRIPTION
36
37 This is a simple tool for helping to develop Perl::Critic::Policy
38 modules.  If you want to see how L<PPI> would parse a snippet of
39 code, just feed it to C<ppidump>.
40
41 By default, whitespace tokens are hidden.  Use the C<-w> flag to show
42 them.
43
44 =head1 AUTHOR
45
46 Jeffrey Ryan Thalhammer <thaljef@cpan.org>
47
48 =head1 COPYRIGHT
49
50 Copyright (c) 2005-2008 Jeffrey Ryan Thalhammer.  All rights reserved.
51
52 This program is free software; you can redistribute it and/or modify
53 it under the same terms as Perl itself.  The full text of this license
54 can be found in the LICENSE file included with this module.
55
56 =cut
57
58 ##############################################################################
59 # Local Variables:
60 #   mode: cperl
61 #   cperl-indent-level: 4
62 #   fill-column: 78
63 #   indent-tabs-mode: nil
64 #   c-indentation-style: bsd
65 # End:
66 # ex: set ts=8 sts=4 sw=4 tw=78 ft=perl expandtab shiftround :