1PPIx::QuoteLike::DumperU(s3e)r Contributed Perl DocumentaPtPiIoxn::QuoteLike::Dumper(3)
2
3
4
6 PPIx::QuoteLike::Dumper - Dump the results of parsing quotelike things
7
9 use PPIx::QuoteLike::Dumper;
10 PPIx::QuoteLike::Dumper->new( '"foo$bar baz"' )
11 ->print();
12
14 This class generates a formatted dump of a PPIx::QuoteLike object, or a
15 string that can be made into such an object.
16
18 This class supports the following public methods. Methods not
19 documented here are private, and unsupported in the sense that the
20 author reserves the right to change or remove them without notice.
21
22 new
23 my $dumper = PPIx::QuoteLike::Dumper->new(
24 '"foo$bar baz"',
25 variables => 1,
26 );
27
28 This static method instantiates the dumper. It takes the string or
29 PPIx::QuoteLike object to be dumped as the first argument. Optional
30 further arguments may be passed as name/value pairs.
31
32 The following optional arguments are recognized:
33
34 encoding name
35 This argument is the encoding of the object to be dumped. It is
36 passed through to PPIx::QuoteLike new() unless the first argument
37 was a PPIx::QuoteLike object, in which case it is ignored.
38
39 indent number
40 This argument specifies the number of additional spaces to indent
41 each level of the parse hierarchy. This is ignored if the "tokens"
42 argument is true.
43
44 The default is 2.
45
46 margin number
47 This argument is the number of additional spaces to indent the
48 parse hierarchy, over those specified by the margin.
49
50 The default is 0.
51
52 perl_version Boolean
53 This argument specifies whether or not the perl versions introduced
54 and removed are included in the dump.
55
56 The default is 0 (i.e. false).
57
58 postderef Boolean
59 This argument specifies whether or not postfix dereferences are
60 recognized in interpolations. It is passed through to
61 PPIx::QuoteLike new() unless the first argument was a
62 PPIx::QuoteLike object, in which case it is ignored.
63
64 ppi Boolean
65 This argument specifies whether or not a PPI dump is provided for
66 interpolations.
67
68 The default is 0 (i.e. false).
69
70 tokens boolean
71 If true, this argument causes an unstructured dump of tokens found
72 in the parse.
73
74 The default is 0 (i.e. false).
75
76 variables Boolean
77 If true, this argument causes all variables actually interpolated
78 by any interpolations to be dumped.
79
80 The default is 0 (i.e. false).
81
82 dump
83 print PPIx::Regexp::Dumper->dump( 'foo/bar.pl',
84 variables => 1,
85 );
86
87 This static method returns a string that represents a dump of its first
88 argument. It takes the same optional arguments as new(). This method
89 differs from new() in its interpretation of the first argument.
90
91 · If the first argument is the name of a file, or is a SCALAR
92 reference, it is made into a PPI::Document and all strings in the
93 document are dumped.
94
95 · If the first argument is a PPI::Node all strings in the node are
96 dumped. Note that a PPI::Document is a PPI::Node.
97
98 Otherwise the first argument is handled just like new() would handle
99 it.
100
101 The return is the string representation of the dump.
102
103 In addition to the optional arguments accepted by new(), the following
104 can be specified:
105
106 none
107 This argument specifies a string to return if no dump can be
108 produced (typically because the first argument is neither a file
109 name nor text that is recognized by this package). If unspecified,
110 or specified as "undef", nothing is returned in this case.
111
112 The output for an individual quote-like object differs from the
113 string() output on the same object in that it is preceded by the
114 literal sting being dumped, and file and location information if that
115 can be determined.
116
117 list
118 print map { "$_\n" } $dumper->list();
119
120 This method returns an array containing the dump output. one line per
121 element. The output has no left margin applied, and no trailing
122 newlines. Embedded newlines are probable if the "ppi" argument was
123 specified when the dumper was instantiated.
124
125 print
126 $dumper->print();
127
128 This method simply prints the result of "string" to standard out.
129
130 string
131 print $dumper->string();
132
133 This method adds left margin and newlines to the output of "list",
134 concatenates the result into a single string, and returns that string.
135
137 Support is by the author. Please file bug reports at
138 <http://rt.cpan.org>, or in electronic mail to the author.
139
141 Thomas R. Wyant, III wyant at cpan dot org
142
144 Copyright (C) 2016-2019 by Thomas R. Wyant, III
145
146 This program is free software; you can redistribute it and/or modify it
147 under the same terms as Perl 5.10.0. For more details, see the full
148 text of the licenses in the directory LICENSES.
149
150 This program is distributed in the hope that it will be useful, but
151 without any warranty; without even the implied warranty of
152 merchantability or fitness for a particular purpose.
153
154
155
156perl v5.28.2 2019-05-31 PPIx::QuoteLike::Dumper(3)