PPIx::QuoteLike::Dumper(3) User Contributed Perl Documentation PPIx::QuoteLike::Dumper(3)

PPIx::QuoteLike::Dumper - Dump the results of parsing quotelike things

use PPIx::QuoteLike::Dumper;
PPIx::QuoteLike::Dumper->new( '"foo$bar baz"' )
  ->print();

This class generates a formatted dump of a PPIx::QuoteLike object, or a string that can be made into such an object.

This class supports the following public methods. Methods not documented here are private, and unsupported in the sense that the author reserves the right to change or remove them without notice.

my $dumper = PPIx::QuoteLike::Dumper->new(
    '"foo$bar baz"',
    variables  => 1,
);

This static method instantiates the dumper. It takes the string or PPIx::QuoteLike object to be dumped as the first argument. Optional further arguments may be passed as name/value pairs.

The following optional arguments are recognized:

This argument is the encoding of the object to be dumped. It is passed through to PPIx::QuoteLike new() unless the first argument was a PPIx::QuoteLike object, in which case it is ignored.
This argument specifies the number of additional spaces to indent each level of the parse hierarchy. This is ignored if the "tokens" argument is true.

The default is 2.

This argument is the number of additional spaces to indent the parse hierarchy, over those specified by the margin.

The default is 0.

This argument specifies whether or not the perl versions introduced and removed are included in the dump.

The default is 0 (i.e. false).

THIS ARGUMENT IS DEPRECATED. See DEPRECATION NOTICE in PPIx::QuoteLike for the details.

This argument specifies whether or not postfix dereferences are recognized in interpolations. It is passed through to PPIx::QuoteLike new() unless the first argument was a PPIx::QuoteLike object, in which case it is ignored.

This argument specifies whether or not a PPI dump is provided for interpolations.

The default is 0 (i.e. false).

If true, leading 'PPIx::QuoteLike::' will be removed from the class names in the output.
If true, this argument causes an unstructured dump of tokens found in the parse.

The default is 0 (i.e. false).

If true, this argument causes all variables actually interpolated by any interpolations to be dumped.

The default is 0 (i.e. false).

print PPIx::Regexp::Dumper->dump( 'foo/bar.pl',
    variables => 1,
);

This static method returns a string that represents a dump of its first argument. It takes the same optional arguments as new(). This method differs from new() in its interpretation of the first argument.

  • If the first argument is the name of a file, or is a SCALAR reference, it is made into a PPI::Document and all strings in the document are dumped.
  • If the first argument is a PPI::Node all strings in the node are dumped. Note that a PPI::Document is a PPI::Node.

Otherwise the first argument is handled just like new() would handle it.

The return is the string representation of the dump.

In addition to the optional arguments accepted by new(), the following can be specified:

This argument specifies a string to return if no dump can be produced (typically because the first argument is neither a file name nor text that is recognized by this package). If unspecified, or specified as "undef", nothing is returned in this case.

The output for an individual quote-like object differs from the string() output on the same object in that it is preceded by the literal sting being dumped, and file and location information if that can be determined.

print map { "$_\n" } $dumper->list();

This method returns an array containing the dump output. one line per element. The output has no left margin applied, and no trailing newlines. Embedded newlines are probable if the "ppi" argument was specified when the dumper was instantiated.

$dumper->print();

This method simply prints the result of "string" to standard out.

print $dumper->string();

This method adds left margin and newlines to the output of "list", concatenates the result into a single string, and returns that string.

Support is by the author. Please file bug reports at https://rt.cpan.org/Public/Dist/Display.html?Name=PPIx-QuoteLike, https://github.com/trwyant/perl-PPIx-QuoteLike/issues, or in electronic mail to the author.

Thomas R. Wyant, III wyant at cpan dot org

Copyright (C) 2016-2022 by Thomas R. Wyant, III

This program is free software; you can redistribute it and/or modify it under the same terms as Perl 5.10.0. For more details, see the full text of the licenses in the directory LICENSES.

This program is distributed in the hope that it will be useful, but without any warranty; without even the implied warranty of merchantability or fitness for a particular purpose.

2024-09-01 perl v5.40.0