Data-Dump-Streamer
view release on metacpan or search on metacpan
lib/Data/Dump/Streamer.pm view on Meta::CPAN
# print DDumper(PadWalker::peek_my(1));
# return $self;
#}
return wantarray ? @{ $self->{unames} || [] } : $self->{unames};
}
=item Terse
=item Terse BOOL
When true, no variable names will be created. Data will be dumped as
anonymous references or values.
Dump([])->Out; # $ARRAY1 = []
Dump([])->Terse(1)->Out; # []
=cut
sub Terse {
my $self= shift->_safe_self;
if (@_) {
$self->{style}{terse}= shift;
return $self;
}
else {
return $self->{style}{terse};
}
}
=for UEDIT
sub Purity {}
=item Purity
=item Purity BOOL
This option can be used to set the level of purity in the output. It
defaults to TRUE, which results in the module doing its best to ensure
that the resulting dump when eval()ed is precisely the same as the input.
However, at times such as debugging this can be tedious, resulting in
extremely long dumps with many "fix" statements involved. By setting
Purity to FALSE the resulting output won't necessarily be legal Perl, but
it will be more legible. In this mode the output is broadly similar to
that of the default setting of Data::Dumper (Purity(0)). When set to TRUE
the behaviour is likewise similar to Data::Dumper in Purity(1) but more
accurate.
When Purity() is set to FALSE aliases will be output with a function call
wrapper of 'alias_to' whose argument will be the value the item is an
alias to. This wrapper does nothing, and is only there as a visual cue.
Likewise, 'make_ro' will be output when the value was readonly, and again
the effect is cosmetic only.
=item To
=item To STREAMER
Specifies the object to print to. Data::Dump::Streamer can stream its
output to any object supporting the print method. This is primarily meant
for streaming to a filehandle, however any object that supports the method
will do.
If a filehandle is specified then it is used until it is explicitly
changed, or the object is destroyed.
=cut
sub To {
my $self= shift->_safe_self;
if (@_) {
$self->{fh}= shift;
return $self;
}
return $self->{fh};
}
=for UEDIT
sub Declare {}
=item Declare
=item Declare BOOL
If Declare is True then each object is dumped with 'my' declarations
included, and all rules that follow are obeyed. (Ie, not referencing an
undeclared variable). If Declare is False then all objects are expected to
be previously defined and references to top level objects can be made at
any time.
Defaults to False.
=cut
sub Indent {
my $self= shift->_safe_self();
if (@_) {
my $val= shift;
if ($val == 0 && length $self->{style}{optspace}) {
$self->{style}{last_optspace}= $self->{style}{optspace};
$self->{style}{optspace}= "";
}
elsif (!$self->{style}{indent} && !length $self->{style}{optspace}) {
$self->{style}{optspace}= $self->{style}{last_optspace};
}
$self->{style}{indent}= $val;
return $self;
}
else {
return $self->{style}{indent};
}
}
=item Indent
=item Indent INT
If Indent is True then data is output in an indented and fairly neat
fashion. If the value is 2 then hash key/value pairs and array values each
on their own line. If the value is 1 then a "smart" indenting mode is
( run in 1.297 second using v1.01-cache-2.11-cpan-bbb979687b5 )